Enable autoSearchPaths to match pyright's CLI#222
Open
dreddnafious wants to merge 1 commit into
Open
Conversation
pyright's own CLI sets `autoSearchPaths = true` unconditionally
("Always enable autoSearchPaths when using the command line",
pyright-internal/src/common/configOptions.ts consumer in pyright.ts).
scip-python replaces that entry point and never sets the field, so
`commandLineOptions.autoSearchPaths || false` is always false and
ensureDefaultExtraPaths() never adds ./src.
The effect is silent: for a src-layout project with no [tool.pyright]
section, definitions are emitted under `src.pkg.mod` while imports
resolve to `pkg.mod`, so every reference from outside src/ is dropped
from the index. The run exits 0 and the index is simply smaller.
An explicit extraPaths still takes precedence, so projects that already
configure pyright are unaffected.
Fixes sourcegraph#221
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Fixes #221.
scip-pythonbuilds its ownCommandLineOptionsand never setsautoSearchPaths, soensureDefaultExtraPaths()never adds./src. pyright's CLI sets it unconditionally:Since
pyright-scipreplaces that entry point, the setting is lost, andsrc-layout projectsindex with definitions under
src.pkg.modwhile imports resolve topkg.mod. The two namespacesnever join, so cross-package references are dropped. The run exits 0 and the index is just smaller.
Verification
Minimal project, no
[tool.pyright]section:Before — the reference to
handleris absent entirely:After (equivalently, with
extraPaths = ["src"]set manually on 0.6.6):For comparison,
pyrightitself resolves this tree with no configuration at all — same directory,no
[tool.pyright]:So
pyrightandscip-pythoncurrently disagree about the same project.Safety
ensureDefaultExtraPathsappliesautoSearchPathsand explicitextraPathsindependently, andthe auto-detected path is only added when
./srcexists and is not itself a package(
src/__init__.pyabsent). Projects that already configureextraPathsinpyrightconfig.jsonor
[tool.pyright]are unaffected; projects with asrcpackage directory are unaffected.Note on tests
I did not add a snapshot fixture. A
snapshots/input/src_layout/case (asrc/-rooted packageplus an importer outside
src/) would cover this well, but the expected output has to come fromnpm run update-snapshotsagainst a build, and I would rather not hand-write generated output Ican't verify. Happy to add it if you'd like — just say the word and I'll build and generate it
properly.
Environment
scipbranch and@sourcegraph/scip-python0.6.6 (current npm latest)pyright1.1.411