summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Crosley <timothy.crosley@gmail.com>2021-07-23 22:47:44 -0700
committerTimothy Crosley <timothy.crosley@gmail.com>2021-07-23 22:47:44 -0700
commit3afcb2dac3d8208ffeb1400c5208e0a3877923c3 (patch)
treec2e71d0adff8193f188c38394773ba4d6cb80c9f
parent0d4f1fab342017dddd8b914f71cf6938ac7ac622 (diff)
parentf3116272c50b3be68d4d3750ae6b6105893d1cc2 (diff)
downloadisort-3afcb2dac3d8208ffeb1400c5208e0a3877923c3.tar.gz
Merge branch 'main' of https://github.com/timothycrosley/isort
-rw-r--r--isort/settings.py7
-rwxr-xr-xscripts/build_config_option_docs.py7
-rw-r--r--tests/unit/test_isort.py4
-rw-r--r--tests/unit/test_main.py23
4 files changed, 30 insertions, 11 deletions
diff --git a/isort/settings.py b/isort/settings.py
index 555ad46e..ee729744 100644
--- a/isort/settings.py
+++ b/isort/settings.py
@@ -552,11 +552,10 @@ class Config(_Config):
# don't check symlinks; either part of the repo and would be checked
# twice, or is external to the repo and git won't know anything about it
for root, _dirs, git_files in os.walk(git_folder, followlinks=False):
+ if ".git" in _dirs:
+ _dirs.remove(".git")
for git_file in git_files:
- git_path = os.path.join(root, git_file)
- # followlinks only disables walking into linked dirs
- if not os.path.islink(git_path): # pragma: no cover
- files.append(git_path)
+ files.append(os.path.join(root, git_file))
git_options = ["-C", str(git_folder), "-c", "core.quotePath="]
try:
ignored = subprocess.check_output( # nosec # skipcq: PYL-W1510
diff --git a/scripts/build_config_option_docs.py b/scripts/build_config_option_docs.py
index 15a3db53..899e0fef 100755
--- a/scripts/build_config_option_docs.py
+++ b/scripts/build_config_option_docs.py
@@ -153,10 +153,7 @@ def human(name: str) -> str:
def config_options() -> Generator[ConfigOption, None, None]:
- cli_actions = {}
- for action in parser._actions:
- cli_actions[action.dest] = action
-
+ cli_actions = {action.dest: action for action in parser._actions}
for name, default in config.items():
extra_kwargs = {}
@@ -168,7 +165,7 @@ def config_options() -> Generator[ConfigOption, None, None]:
default_display = default
if isinstance(default, (set, frozenset)) and len(default) > 0:
- default_display = tuple(i for i in sorted(default))
+ default_display = tuple(sorted(default))
# todo: refactor place for example params
# needs to integrate with isort/settings/_Config
diff --git a/tests/unit/test_isort.py b/tests/unit/test_isort.py
index 526a7b8a..f6f905fd 100644
--- a/tests/unit/test_isort.py
+++ b/tests/unit/test_isort.py
@@ -2708,7 +2708,7 @@ def test_import_by_paren_issue_375() -> None:
def test_import_by_paren_issue_460() -> None:
- """Test to ensure isort can doesnt move comments around """
+ """Test to ensure isort can doesnt move comments around"""
test_input = """
# First comment
# Second comment
@@ -5184,7 +5184,7 @@ def test_only_sections() -> None:
def test_combine_straight_imports() -> None:
- """ Tests to ensure that combine_straight_imports works correctly """
+ """Tests to ensure that combine_straight_imports works correctly"""
test_input = (
"import os\n" "import sys\n" "# this is a comment\n" "import math # inline comment\n"
diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py
index 84cc3e11..2b13f9aa 100644
--- a/tests/unit/test_main.py
+++ b/tests/unit/test_main.py
@@ -1188,3 +1188,26 @@ nested_dir_ignored
out, error = main_check([str(tmpdir), "--skip-gitignore", "--filter-files"])
assert all(f"{str(tmpdir)}{file}" in out for file in should_check)
+
+ # Should work when git project contains symlinks
+
+ if os.name != "nt":
+ git_project0.join("has_imports_ignored.py").write(import_content)
+ git_project0.join("has_imports.py").write(import_content)
+ tmpdir.join("has_imports.py").write(import_content)
+ tmpdir.join("nested_dir").join("has_imports.py").write(import_content)
+ git_project0.join("ignore_link.py").mksymlinkto(tmpdir.join("has_imports.py"))
+ git_project0.join("ignore_link").mksymlinkto(tmpdir.join("nested_dir"))
+ git_project0.join(".gitignore").write("ignore_link.py\nignore_link", mode="a")
+
+ out, error = main_check(
+ [str(git_project0), "--skip-gitignore", "--filter-files", "--check"]
+ )
+
+ should_check = ["/git_project0/has_imports.py"]
+
+ assert all(f"{str(tmpdir)}{file}" in error for file in should_check)
+
+ out, error = main_check([str(git_project0), "--skip-gitignore", "--filter-files"])
+
+ assert all(f"{str(tmpdir)}{file}" in out for file in should_check)