Repository navigation
fix: keep symlink discovery within Git project boundaries - #2719
Open
Yurii201811 wants to merge 3 commits into
Open
Yurii201811 wants to merge 3 commits into
Yurii201811 wants to merge 3 commits into
Conversation
ucodery
requested changes
Oct 20, 2026
ucodery
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for this thoughtful implementation, it seems to fully address the problem for git projects.
| ## Follow Links | ||
|
|
||
| If `True` isort will follow symbolic links when doing recursive sorting. | ||
| If `True` isort will follow symbolic links during path discovery. Symlinks in a Git repository are followed only when their targets remain inside that repository, including links passed explicitly to the CLI or `find_imports_in_paths`. Symlinks outside Git repositories retain the existing behavior. Direct `sort_file` API calls continue to operate on the exact file supplied. |
Collaborator
There was a problem hiding this comment.
This is good changelog copy, but as user docs the reader won't have any context about historic behaviour, or need to use the API. It should probably read as "for all other repositories, symlinks are always followed"
Collaborator
There was a problem hiding this comment.
The CHANGELOG should get an entry closer to what this is now, and that entry should specifically call out that this is a potential breaking change to users.
| "If `True` isort will follow symbolic links during path discovery. Symlinks in a Git " | ||
| "repository are followed only when their targets remain inside that repository, including " | ||
| "links passed explicitly to the CLI or `find_imports_in_paths`. Symlinks outside Git " | ||
| "repositories retain the existing behavior. Direct `sort_file` API calls continue to operate " |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
isort can follow a project symlink and rewrite Python files outside that project. I bound path discovery to the containing Git repository, including explicit file arguments and repositories accessed through a symlinked parent. Internal links and discovery outside Git repositories keep their existing behavior.
The Follow Links documentation and its generator describe the boundary. Direct
sort_filecalls continue to operate on the supplied file.Closes #1788.
Validation
uvinstall; Python 3.14.7 on macOS../scripts/test.sh: 681 passed, one skipped, 99% coverage.uv run --with tox-uv tox -e lint: passes all configured checks.92c56855, including the CLI modifying an external file.The Linux/Windows and compiled-build CI matrix has not run locally. Symlink tests retain a Windows skip because creating links requires additional privileges.