Skip to content

Commit c36414d

Browse files
Merge branch 'main' of https://github.com/timothycrosley/isort into issue/1769
2 parents b444003 + f44b5a5 commit c36414d

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ Changelog
44
NOTE: isort follows the [semver](https://semver.org/) versioning standard.
55
Find out more about isort's release policy [here](https://pycqa.github.io/isort/docs/major_releases/release_policy).
66

7-
### 5.9.2
7+
### 5.9.2 TBD
88
- Improved behavior of `isort --check --atomic` against Cython files.
99
- Fixed #1769: Future imports added below assignments when no other imports present.
10+
- Fixed #1772: skip-gitignore will check files not in the git repository.
11+
- Fixed #1762: in some cases when skip-gitignore is set, isort fails to skip any files.
1012

1113
### 5.9.1 June 21st 2021 [hotfix]
1214
- Fixed #1758: projects with many files and skip_ignore set can lead to a command-line overload.

docs/configuration/options.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ Force all imports to be sorted as a single section
622622

623623
## Force Grid Wrap
624624

625-
Force number of from imports (defaults to 2 when passed as CLI flag without value)to be grid wrapped regardless of line length. If 0 is passed in (the global default) only line length is considered.
625+
Force number of from imports (defaults to 2 when passed as CLI flag without value) to be grid wrapped regardless of line length. If 0 is passed in (the global default) only line length is considered.
626626

627627
**Type:** Int
628628
**Default:** `0`

isort/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ def _build_arg_parser() -> argparse.ArgumentParser:
472472
const=2,
473473
type=int,
474474
dest="force_grid_wrap",
475-
help="Force number of from imports (defaults to 2 when passed as CLI flag without value)"
475+
help="Force number of from imports (defaults to 2 when passed as CLI flag without value) "
476476
"to be grid wrapped regardless of line "
477477
"length. If 0 is passed in (the global default) only line length is considered.",
478478
)

isort/settings.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,15 @@ def _check_folder_gitignore(self, folder: str) -> Optional[Path]:
548548

549549
git_folder = Path(topfolder_result.rstrip()).resolve()
550550

551-
files = [str(p) for p in Path(git_folder).rglob("*")]
551+
files: List[str] = []
552+
# don't check symlinks; either part of the repo and would be checked
553+
# twice, or is external to the repo and git won't konw anything about it
554+
for root, _dirs, git_files in os.walk(git_folder, followlinks=False):
555+
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):
559+
files.append(git_path)
552560
git_options = ["-C", str(git_folder), "-c", "core.quotePath="]
553561
try:
554562
ignored = subprocess.check_output( # nosec # skipcq: PYL-W1510

0 commit comments

Comments
 (0)