summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstaticdev <staticdev-support@protonmail.com>2023-02-21 21:05:06 +0100
committerstaticdev <staticdev-support@protonmail.com>2023-02-21 21:14:19 +0100
commit869dc583a9de7dc25fb06320949ddd294afc1f42 (patch)
tree05937a46ab93b921b3dc7ceb8b2f68c164a4c870
parent29d306d48feb3fb2864c448973d4637dc4291fab (diff)
parent4114c33f29199c5092a4263c5a2c7397d157990b (diff)
downloadisort-869dc583a9de7dc25fb06320949ddd294afc1f42.tar.gz
Fix linting issues
-rw-r--r--.flake83
-rw-r--r--docs/configuration/config_files.md2
-rw-r--r--isort/deprecated/finders.py2
-rw-r--r--isort/settings.py6
-rw-r--r--poetry.lock70
-rw-r--r--tests/unit/test_settings.py8
-rw-r--r--tests/unit/test_ticketed_features.py2
7 files changed, 40 insertions, 53 deletions
diff --git a/.flake8 b/.flake8
index 2ca44a12..bc8c5000 100644
--- a/.flake8
+++ b/.flake8
@@ -3,7 +3,8 @@ max-line-length = 100
# Ignore non PEP 8 compliant rules as suggested by black
extend-ignore =
E203, # https://github.com/psf/black/blob/master/docs/the_black_code_style.md#slices
- E501
+ E501,
+ B017
exclude = _vendored
per-file-ignores =
isort/__init__.py:F401
diff --git a/docs/configuration/config_files.md b/docs/configuration/config_files.md
index 88b8a4ad..df8c1009 100644
--- a/docs/configuration/config_files.md
+++ b/docs/configuration/config_files.md
@@ -115,4 +115,4 @@ directory_root
isort will sort `subdir1/file1` according to the configurations defined in `subdir1/.isort.cfg`, `subdir2/file2` with configurations from `subdir2/pyproject.toml` and `subdir3/file3.py` based on the `setup.cfg` settings.
!!! tip
-You can always confirm exactly what config file was used for a file by running isort with the `--verbose` flag.
+ You can always confirm exactly what config file was used for a file by running isort with the `--verbose` flag.
diff --git a/isort/deprecated/finders.py b/isort/deprecated/finders.py
index 55e8f8b8..eac650e2 100644
--- a/isort/deprecated/finders.py
+++ b/isort/deprecated/finders.py
@@ -332,7 +332,7 @@ class RequirementsFinder(ReqsBaseFinder):
result = []
with chdir(os.path.dirname(path)):
- requirements = parse_requirements(path)
+ requirements = parse_requirements(Path(path))
for req in requirements.values():
if req.name:
result.append(req.name)
diff --git a/isort/settings.py b/isort/settings.py
index a5502764..500275f7 100644
--- a/isort/settings.py
+++ b/isort/settings.py
@@ -11,7 +11,6 @@ import stat
import subprocess # nosec: Needed for gitignore support.
import sys
from dataclasses import dataclass, field
-from functools import lru_cache
from pathlib import Path
from typing import (
TYPE_CHECKING,
@@ -766,7 +765,6 @@ def _abspaths(cwd: str, values: Iterable[str]) -> Set[str]:
return paths
-@lru_cache()
def _find_config(path: str) -> Tuple[str, Dict[str, Any]]:
current_directory = path
tries = 0
@@ -799,7 +797,6 @@ def _find_config(path: str) -> Tuple[str, Dict[str, Any]]:
return (path, {})
-@lru_cache()
def find_all_configs(path: str) -> Trie:
"""
Looks for config files in the path provided and in all of its sub-directories.
@@ -828,8 +825,7 @@ def find_all_configs(path: str) -> Trie:
return trie_root
-@lru_cache()
-def _get_config_data(file_path: str, sections: Tuple[str]) -> Dict[str, Any]:
+def _get_config_data(file_path: str, sections: Tuple[str, ...]) -> Dict[str, Any]:
settings: Dict[str, Any] = {}
if file_path.endswith(".toml"):
diff --git a/poetry.lock b/poetry.lock
index 39f57f24..029c84c9 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -650,14 +650,14 @@ gitdb = ">=4.0.1"
[[package]]
name = "gitpython"
-version = "3.1.30"
-description = "GitPython is a python library used to interact with Git repositories"
+version = "3.1.31"
+description = "GitPython is a Python library used to interact with Git repositories"
category = "dev"
optional = false
python-versions = ">=3.7"
files = [
- {file = "GitPython-3.1.30-py3-none-any.whl", hash = "sha256:cd455b0000615c60e286208ba540271af9fe531fa6a87cc590a7298785ab2882"},
- {file = "GitPython-3.1.30.tar.gz", hash = "sha256:769c2d83e13f5d938b7688479da374c4e3d49f71549aaf462b646db9602ea6f8"},
+ {file = "GitPython-3.1.31-py3-none-any.whl", hash = "sha256:f04893614f6aa713a60cbbe1e6a97403ef633103cdd0ef5eb6efe0deb98dbe8d"},
+ {file = "GitPython-3.1.31.tar.gz", hash = "sha256:8ce3bcf69adfdf7c7d503e78fd3b1c492af782d58893b650adb2ac8912ddd573"},
]
[package.dependencies]
@@ -739,14 +739,14 @@ requests = "*"
[[package]]
name = "hypothesis"
-version = "6.68.0"
+version = "6.68.2"
description = "A library for property-based testing"
category = "dev"
optional = false
python-versions = ">=3.7"
files = [
- {file = "hypothesis-6.68.0-py3-none-any.whl", hash = "sha256:064a5bf7a98cbdfa3589d8934a2c548524c6d108bfa368ec5ed8b09caa526108"},
- {file = "hypothesis-6.68.0.tar.gz", hash = "sha256:8cfa1de15271debb2750545a460e58e3e84527d94157f38ab9309826953572f3"},
+ {file = "hypothesis-6.68.2-py3-none-any.whl", hash = "sha256:2a41cc766cde52705895e54547374af89c617e8ec7bc4186cb7f03884a667d4e"},
+ {file = "hypothesis-6.68.2.tar.gz", hash = "sha256:a7eb2b0c9a18560d8197fe35047ceb58e7e8ab7623a3e5a82613f6a2cd71cffa"},
]
[package.dependencies]
@@ -789,14 +789,14 @@ libcst = ">=0.4.0"
[[package]]
name = "identify"
-version = "2.5.17"
+version = "2.5.18"
description = "File identification library for Python"
category = "dev"
optional = false
python-versions = ">=3.7"
files = [
- {file = "identify-2.5.17-py2.py3-none-any.whl", hash = "sha256:7d526dd1283555aafcc91539acc061d8f6f59adb0a7bba462735b0a318bff7ed"},
- {file = "identify-2.5.17.tar.gz", hash = "sha256:93cc61a861052de9d4c541a7acb7e3dcc9c11b398a2144f6e52ae5285f5f4f06"},
+ {file = "identify-2.5.18-py2.py3-none-any.whl", hash = "sha256:93aac7ecf2f6abf879b8f29a8002d3c6de7086b8c28d88e1ad15045a15ab63f9"},
+ {file = "identify-2.5.18.tar.gz", hash = "sha256:89e144fa560cc4cffb6ef2ab5e9fb18ed9f9b3cb054384bab4b95c12f6c309fe"},
]
[package.extras]
@@ -1439,14 +1439,14 @@ files = [
[[package]]
name = "pip"
-version = "23.0"
+version = "23.0.1"
description = "The PyPA recommended tool for installing Python packages."
category = "main"
optional = false
python-versions = ">=3.7"
files = [
- {file = "pip-23.0-py3-none-any.whl", hash = "sha256:b5f88adff801f5ef052bcdef3daa31b55eb67b0fccd6d0106c206fa248e0463c"},
- {file = "pip-23.0.tar.gz", hash = "sha256:aee438284e82c8def684b0bcc50b1f6ed5e941af97fa940e83e2e8ef1a59da9b"},
+ {file = "pip-23.0.1-py3-none-any.whl", hash = "sha256:236bcb61156d76c4b8a05821b988c7b8c35bf0da28a4b614e8d6ab5212c25c6f"},
+ {file = "pip-23.0.1.tar.gz", hash = "sha256:cd015ea1bfb0fcef59d8a286c1f8bebcb983f6317719d415dc5351efb7cd7024"},
]
[[package]]
@@ -1576,14 +1576,14 @@ virtualenv = ">=20.10.0"
[[package]]
name = "prompt-toolkit"
-version = "3.0.36"
+version = "3.0.37"
description = "Library for building powerful interactive command lines in Python"
category = "dev"
optional = false
-python-versions = ">=3.6.2"
+python-versions = ">=3.7.0"
files = [
- {file = "prompt_toolkit-3.0.36-py3-none-any.whl", hash = "sha256:aa64ad242a462c5ff0363a7b9cfe696c20d55d9fc60c11fd8e632d064804d305"},
- {file = "prompt_toolkit-3.0.36.tar.gz", hash = "sha256:3e163f254bef5a03b146397d7c1963bd3e2812f0964bb9a24e6ec761fd28db63"},
+ {file = "prompt_toolkit-3.0.37-py3-none-any.whl", hash = "sha256:6a2948ec427dfcc7c983027b1044b355db6aaa8be374f54ad2015471f7d81c5b"},
+ {file = "prompt_toolkit-3.0.37.tar.gz", hash = "sha256:d5d73d4b5eb1a92ba884a88962b157f49b71e06c4348b417dd622b25cdd3800b"},
]
[package.dependencies]
@@ -2059,14 +2059,14 @@ gitlab = ["python-gitlab (>=1.3.0)"]
[[package]]
name = "setuptools"
-version = "67.2.0"
+version = "67.4.0"
description = "Easily download, build, install, upgrade, and uninstall Python packages"
category = "main"
optional = false
python-versions = ">=3.7"
files = [
- {file = "setuptools-67.2.0-py3-none-any.whl", hash = "sha256:16ccf598aab3b506593c17378473978908a2734d7336755a8769b480906bec1c"},
- {file = "setuptools-67.2.0.tar.gz", hash = "sha256:b440ee5f7e607bb8c9de15259dba2583dd41a38879a7abc1d43a71c59524da48"},
+ {file = "setuptools-67.4.0-py3-none-any.whl", hash = "sha256:f106dee1b506dee5102cc3f3e9e68137bbad6d47b616be7991714b0c62204251"},
+ {file = "setuptools-67.4.0.tar.gz", hash = "sha256:e5fd0a713141a4a105412233c63dc4e17ba0090c8e8334594ac790ec97792330"},
]
[package.extras]
@@ -2171,14 +2171,14 @@ tests = ["cython", "littleutils", "pygments", "pytest", "typeguard"]
[[package]]
name = "stevedore"
-version = "4.1.1"
+version = "5.0.0"
description = "Manage dynamic plugins for Python applications"
category = "dev"
optional = false
python-versions = ">=3.8"
files = [
- {file = "stevedore-4.1.1-py3-none-any.whl", hash = "sha256:aa6436565c069b2946fe4ebff07f5041e0c8bf18c7376dd29edf80cf7d524e4e"},
- {file = "stevedore-4.1.1.tar.gz", hash = "sha256:7f8aeb6e3f90f96832c301bff21a7eb5eefbe894c88c506483d355565d88cc1a"},
+ {file = "stevedore-5.0.0-py3-none-any.whl", hash = "sha256:bd5a71ff5e5e5f5ea983880e4a1dd1bb47f8feebbb3d95b592398e2f02194771"},
+ {file = "stevedore-5.0.0.tar.gz", hash = "sha256:2c428d2338976279e8eb2196f7a94910960d9f7ba2f41f3988511e95ca447021"},
]
[package.dependencies]
@@ -2292,14 +2292,14 @@ test = ["black (>=22.3.0,<23.0.0)", "coverage (>=6.2,<7.0)", "isort (>=5.0.6,<6.
[[package]]
name = "types-colorama"
-version = "0.4.15.7"
+version = "0.4.15.8"
description = "Typing stubs for colorama"
category = "dev"
optional = false
python-versions = "*"
files = [
- {file = "types-colorama-0.4.15.7.tar.gz", hash = "sha256:da84e8abe95c2e11ad2b28ba557ab8e5dc80863bd6f8739e7c1916c950755af4"},
- {file = "types_colorama-0.4.15.7-py3-none-any.whl", hash = "sha256:a060b1440dfc796fbcffcea259f25c3d373381ea3f462e17d48a12cce29b133e"},
+ {file = "types-colorama-0.4.15.8.tar.gz", hash = "sha256:c6bb245aa868c7dd78c3b16bd48484cd366127d61e4efa15676eac23acd82b76"},
+ {file = "types_colorama-0.4.15.8-py3-none-any.whl", hash = "sha256:7ebcb66eb2c672c4f576fc7445a45860eba5f4f05e459de6cea413fac8ef4d2c"},
]
[[package]]
@@ -2316,26 +2316,26 @@ files = [
[[package]]
name = "types-toml"
-version = "0.10.8.3"
+version = "0.10.8.5"
description = "Typing stubs for toml"
category = "dev"
optional = false
python-versions = "*"
files = [
- {file = "types-toml-0.10.8.3.tar.gz", hash = "sha256:f37244eff4cd7eace9cb70d0bac54d3eba77973aa4ef26c271ac3d1c6503a48e"},
- {file = "types_toml-0.10.8.3-py3-none-any.whl", hash = "sha256:a2286a053aea6ab6ff814659272b1d4a05d86a1dd52b807a87b23511993b46c5"},
+ {file = "types-toml-0.10.8.5.tar.gz", hash = "sha256:bf80fce7d2d74be91148f47b88d9ae5adeb1024abef22aa2fdbabc036d6b8b3c"},
+ {file = "types_toml-0.10.8.5-py3-none-any.whl", hash = "sha256:2432017febe43174af0f3c65f03116e3d3cf43e7e1406b8200e106da8cf98992"},
]
[[package]]
name = "typing-extensions"
-version = "4.4.0"
+version = "4.5.0"
description = "Backported and Experimental Type Hints for Python 3.7+"
category = "dev"
optional = false
python-versions = ">=3.7"
files = [
- {file = "typing_extensions-4.4.0-py3-none-any.whl", hash = "sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e"},
- {file = "typing_extensions-4.4.0.tar.gz", hash = "sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa"},
+ {file = "typing_extensions-4.5.0-py3-none-any.whl", hash = "sha256:fb33085c39dd998ac16d1431ebc293a8b3eedd00fd4a32de0ff79002c19511b4"},
+ {file = "typing_extensions-4.5.0.tar.gz", hash = "sha256:5cb5f4a79139d699607b3ef622a1dedafa84e115ab0024e0d9c044a9479ca7cb"},
]
[[package]]
@@ -2511,14 +2511,14 @@ files = [
[[package]]
name = "zipp"
-version = "3.13.0"
+version = "3.14.0"
description = "Backport of pathlib-compatible object wrapper for zip files"
category = "dev"
optional = false
python-versions = ">=3.7"
files = [
- {file = "zipp-3.13.0-py3-none-any.whl", hash = "sha256:e8b2a36ea17df80ffe9e2c4fda3f693c3dad6df1697d3cd3af232db680950b0b"},
- {file = "zipp-3.13.0.tar.gz", hash = "sha256:23f70e964bc11a34cef175bc90ba2914e1e4545ea1e3e2f67c079671883f9cb6"},
+ {file = "zipp-3.14.0-py3-none-any.whl", hash = "sha256:188834565033387710d046e3fe96acfc9b5e86cbca7f39ff69cf21a4128198b7"},
+ {file = "zipp-3.14.0.tar.gz", hash = "sha256:9e5421e176ef5ab4c0ad896624e87a7b2f07aca746c9b2aa305952800cb8eecb"},
]
[package.extras]
diff --git a/tests/unit/test_settings.py b/tests/unit/test_settings.py
index 86354512..295b30c1 100644
--- a/tests/unit/test_settings.py
+++ b/tests/unit/test_settings.py
@@ -126,8 +126,6 @@ def test_find_config(tmpdir):
tmp_config = tmpdir.join(".isort.cfg")
# can't find config if it has no relevant section
- settings._find_config.cache_clear()
- settings._get_config_data.cache_clear()
tmp_config.write_text(
"""
[section]
@@ -138,14 +136,10 @@ force_grid_wrap=true
assert not settings._find_config(str(tmpdir))[1]
# or if it is malformed
- settings._find_config.cache_clear()
- settings._get_config_data.cache_clear()
tmp_config.write_text("""arstoyrsyan arienrsaeinrastyngpuywnlguyn354q^%$)(%_)@$""", "utf8")
assert not settings._find_config(str(tmpdir))[1]
# can when it has either a file format, or generic relevant section
- settings._find_config.cache_clear()
- settings._get_config_data.cache_clear()
_write_simple_settings(tmp_config)
assert settings._find_config(str(tmpdir))[1]
@@ -155,8 +149,6 @@ def test_find_config_deep(tmpdir):
dirs = [f"dir{i}" for i in range(settings.MAX_CONFIG_SEARCH_DEPTH + 1)]
tmp_dirs = tmpdir.ensure(*dirs, dirs=True)
tmp_config = tmpdir.join("dir0", ".isort.cfg")
- settings._find_config.cache_clear()
- settings._get_config_data.cache_clear()
_write_simple_settings(tmp_config)
assert not settings._find_config(str(tmp_dirs))[1]
# but can find config if it is MAX_CONFIG_SEARCH_DEPTH up
diff --git a/tests/unit/test_ticketed_features.py b/tests/unit/test_ticketed_features.py
index 6f483e8f..32eeb709 100644
--- a/tests/unit/test_ticketed_features.py
+++ b/tests/unit/test_ticketed_features.py
@@ -555,7 +555,6 @@ def test_isort_respects_quiet_from_sort_file_api_see_1461(capsys, tmpdir):
assert not out
# Present in an automatically loaded configuration file
- isort.settings._find_config.cache_clear()
settings_file.write(
"""
[isort]
@@ -610,7 +609,6 @@ quiet = true
with pytest.warns(UserWarning):
assert not Config(settings_file=str(settings_file)).quiet
- isort.settings._get_config_data.cache_clear()
settings_file.write(
"""
[isort]