Repository navigation
Conversation
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.
Summary
Clarifies the semantics of the
src_pathsoption in the configuration reference, as requested in #2365.The previous description ("Add an explicitly defined source path (modules within src paths have their imports automatically categorized as first_party)") does not say how a path matches, which leaves three things ambiguous:
src_paths = src, an import is first party only when the module or package behind it lives directly insidesrc/.src/py_compileis first party;srcitself is not.src_pathsis unset, isort silently uses both<project root>/srcand the project root. Declaring onlysrctherefore stops a flat./packagelayout from being classified as first party, which is surprising for anyone who adds the option expecting it to be additive.The new text also documents the one exception to point 1: a root that shares its name with the imported module. With
src_paths = src,import srcis still first party rather than a package nested insidesrc.Related issue
Closes #2365
Changes
docs/configuration/options.md— extended the "Src Paths" section. Docs-only change, no behaviour is altered.Verification
I verified each documented claim against the actual classifier instead of relying on the issue description, using
isort.place.module()against a fixture tree (src/pkg,src/other,rootpkg):Environment: Python 3.13, isort at branch
main(d93953f).Because this is a prose-only edit to a generated reference page, there is no test to add or run. I did not regenerate
docs/configuration/options.mdwithscripts/build_config_option_docs.py: regenerating at the currentHEADalready produces a ~150-line unrelated diff, because the committed page has drifted from its generator (backticked CLI flags, a relative./profiles.mdlink, an updatedskipdefault). I kept this PR focused on the wording and left that pre-existing drift alone; the clarification should also be mirrored into the generator'sdescription_mappingwhenever that drift is fixed, otherwise it will be lost on the next regeneration.