Skip to content

Commit

Permalink
Fixed a bug in the command-line version of pyright where it did not e…
Browse files Browse the repository at this point in the history
…nable "auto search paths", so it didn't automatically add "src" as an extra path. This addresses #4771.
  • Loading branch information
msfterictraut committed Aug 1, 2023
1 parent 567bbc2 commit 050a3c6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/import-resolution.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For absolute (non-relative) imports, Pyright employs the following resolution or

* Try to resolve using any of the **extra paths** defined for the execution environment in the config file. If no execution environment applies, use the `python.analysis.extraPaths` setting. Extra paths are searched in the order in which they are provided in the config file or setting.

* If no execution environment or extraPaths are configured, try to resolve using the **local directory `src`**. It is common for Python projects to place local source files within a directory of this name.
* If no execution environment is configured, try to resolve using the **local directory `src`**. It is common for Python projects to place local source files within a directory of this name.

3. Try to resolve using **stubs or inlined types found within installed packages**. Pyright uses the configured Python environment to determine whether a package has been installed. For more details about how to configure your Python environment for Pyright, see below. If a Python environment is configured, Pyright looks in the `lib/site-packages`, `Lib/site-packages`, or `python*/site-packages` subdirectory. If no site-packages directory can be found, Pyright attempts to run the configured Python interpreter and ask it for its search paths. If no Python environment is configured, Pyright will use the default Python interpreter by invoking `python`.

Expand Down
2 changes: 1 addition & 1 deletion packages/pyright-internal/src/analyzer/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ export class AnalyzerService {
configOptions.defaultPythonVersion = commandLineOptions.pythonVersion;
configOptions.ensureDefaultExtraPaths(
this.fs,
commandLineOptions.autoSearchPaths || false,
commandLineOptions.autoSearchPaths ?? false,
commandLineOptions.extraPaths
);

Expand Down
3 changes: 3 additions & 0 deletions packages/pyright-internal/src/pyright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ async function processArgs(): Promise<ExitStatus> {
options.verboseOutput = true;
}

// Always enable autoSearchPaths when using the command line.
options.autoSearchPaths = true;

if (args.lib) {
console.warn(`The --lib option is deprecated. Pyright now defaults to using library code to infer types.`);
}
Expand Down

0 comments on commit 050a3c6

Please sign in to comment.