Skip to content

Commit

Permalink
Fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
staticdev committed Feb 21, 2023
2 parents 29d306d + 4114c33 commit 869dc58
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 53 deletions.
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/config_files.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion isort/deprecated/finders.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def _get_names_cached(cls, path: str) -> List[str]:
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)
Expand Down
6 changes: 1 addition & 5 deletions isort/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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"):
Expand Down
70 changes: 35 additions & 35 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions tests/unit/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -138,14 +136,10 @@ def test_find_config(tmpdir):
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]

Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/test_ticketed_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -610,7 +609,6 @@ def test_isort_should_warn_on_empty_custom_config_issue_1433(tmpdir):
with pytest.warns(UserWarning):
assert not Config(settings_file=str(settings_file)).quiet

isort.settings._get_config_data.cache_clear()
settings_file.write(
"""
[isort]
Expand Down

0 comments on commit 869dc58

Please sign in to comment.