Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
timothycrosley committed Jul 24, 2021
2 parents 0d4f1fa + f311627 commit 3afcb2d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
7 changes: 3 additions & 4 deletions isort/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,10 @@ def _check_folder_gitignore(self, folder: str) -> Optional[Path]:
# 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
Expand Down
7 changes: 2 additions & 5 deletions scripts/build_config_option_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_isort.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
23 changes: 23 additions & 0 deletions tests/unit/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,3 +1188,26 @@ def main_check(args):
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)

0 comments on commit 3afcb2d

Please sign in to comment.