Skip to content

Commit 3afcb2d

Browse files
committedJul 24, 2021
2 parents 0d4f1fa + f311627 commit 3afcb2d

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed
 

‎isort/settings.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -552,11 +552,10 @@ def _check_folder_gitignore(self, folder: str) -> Optional[Path]:
552552
# don't check symlinks; either part of the repo and would be checked
553553
# twice, or is external to the repo and git won't know anything about it
554554
for root, _dirs, git_files in os.walk(git_folder, followlinks=False):
555+
if ".git" in _dirs:
556+
_dirs.remove(".git")
555557
for git_file in git_files:
556-
git_path = os.path.join(root, git_file)
557-
# followlinks only disables walking into linked dirs
558-
if not os.path.islink(git_path): # pragma: no cover
559-
files.append(git_path)
558+
files.append(os.path.join(root, git_file))
560559
git_options = ["-C", str(git_folder), "-c", "core.quotePath="]
561560
try:
562561
ignored = subprocess.check_output( # nosec # skipcq: PYL-W1510

‎scripts/build_config_option_docs.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,7 @@ def human(name: str) -> str:
153153

154154

155155
def config_options() -> Generator[ConfigOption, None, None]:
156-
cli_actions = {}
157-
for action in parser._actions:
158-
cli_actions[action.dest] = action
159-
156+
cli_actions = {action.dest: action for action in parser._actions}
160157
for name, default in config.items():
161158
extra_kwargs = {}
162159

@@ -168,7 +165,7 @@ def config_options() -> Generator[ConfigOption, None, None]:
168165

169166
default_display = default
170167
if isinstance(default, (set, frozenset)) and len(default) > 0:
171-
default_display = tuple(i for i in sorted(default))
168+
default_display = tuple(sorted(default))
172169

173170
# todo: refactor place for example params
174171
# needs to integrate with isort/settings/_Config

‎tests/unit/test_isort.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2708,7 +2708,7 @@ def test_import_by_paren_issue_375() -> None:
27082708

27092709

27102710
def test_import_by_paren_issue_460() -> None:
2711-
"""Test to ensure isort can doesnt move comments around """
2711+
"""Test to ensure isort can doesnt move comments around"""
27122712
test_input = """
27132713
# First comment
27142714
# Second comment
@@ -5184,7 +5184,7 @@ def test_only_sections() -> None:
51845184

51855185

51865186
def test_combine_straight_imports() -> None:
5187-
""" Tests to ensure that combine_straight_imports works correctly """
5187+
"""Tests to ensure that combine_straight_imports works correctly"""
51885188

51895189
test_input = (
51905190
"import os\n" "import sys\n" "# this is a comment\n" "import math # inline comment\n"

‎tests/unit/test_main.py

+23
Original file line numberDiff line numberDiff line change
@@ -1188,3 +1188,26 @@ def main_check(args):
11881188
out, error = main_check([str(tmpdir), "--skip-gitignore", "--filter-files"])
11891189

11901190
assert all(f"{str(tmpdir)}{file}" in out for file in should_check)
1191+
1192+
# Should work when git project contains symlinks
1193+
1194+
if os.name != "nt":
1195+
git_project0.join("has_imports_ignored.py").write(import_content)
1196+
git_project0.join("has_imports.py").write(import_content)
1197+
tmpdir.join("has_imports.py").write(import_content)
1198+
tmpdir.join("nested_dir").join("has_imports.py").write(import_content)
1199+
git_project0.join("ignore_link.py").mksymlinkto(tmpdir.join("has_imports.py"))
1200+
git_project0.join("ignore_link").mksymlinkto(tmpdir.join("nested_dir"))
1201+
git_project0.join(".gitignore").write("ignore_link.py\nignore_link", mode="a")
1202+
1203+
out, error = main_check(
1204+
[str(git_project0), "--skip-gitignore", "--filter-files", "--check"]
1205+
)
1206+
1207+
should_check = ["/git_project0/has_imports.py"]
1208+
1209+
assert all(f"{str(tmpdir)}{file}" in error for file in should_check)
1210+
1211+
out, error = main_check([str(git_project0), "--skip-gitignore", "--filter-files"])
1212+
1213+
assert all(f"{str(tmpdir)}{file}" in out for file in should_check)

0 commit comments

Comments
 (0)