mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Added command-line option pythonpath
that allows the path to the python interpreter to be specified. This addresses https://github.com/microsoft/pyright/issues/5111.
This commit is contained in:
parent
ba18f421d1
commit
98b0604eb9
@ -13,25 +13,28 @@ Pyright can be run as either a VS Code extension or as a node-based command-line
|
||||
| --level <LEVEL> | Minimum diagnostic level (error or warning) |
|
||||
| --outputjson | Output results in JSON format |
|
||||
| -p, --project `<FILE OR DIRECTORY>` | Use the configuration file at this location |
|
||||
| --pythonpath `<FILE>` | Path to the Python interpreter (2) |
|
||||
| --pythonplatform `<PLATFORM>` | Analyze for platform (Darwin, Linux, Windows) |
|
||||
| --pythonversion `<VERSION>` | Analyze for version (3.3, 3.4, etc.) |
|
||||
| --skipunannotated | Skip type analysis of unannotated functions |
|
||||
| --stats | Print detailed performance stats |
|
||||
| -t, --typeshedpath `<DIRECTORY>` | Use typeshed type stubs at this location (2) |
|
||||
| -v, --venvpath `<DIRECTORY>` | Directory that contains virtual environments (3) |
|
||||
| -t, --typeshedpath `<DIRECTORY>` | Use typeshed type stubs at this location (3) |
|
||||
| -v, --venvpath `<DIRECTORY>` | Directory that contains virtual environments (4) |
|
||||
| --verbose | Emit verbose diagnostics |
|
||||
| --verifytypes `<IMPORT>` | Verify completeness of types in py.typed package |
|
||||
| --version | Print pyright version |
|
||||
| --warnings | Use exit code of 1 if warnings are reported |
|
||||
| -w, --watch | Continue to run and watch for changes (4) |
|
||||
| -w, --watch | Continue to run and watch for changes (5) |
|
||||
|
||||
(1) If specific files are specified on the command line, it overrides the files or directories specified in the pyrightconfig.json or pyproject.toml file.
|
||||
|
||||
(2) Pyright has built-in typeshed type stubs for Python stdlib functionality. To use a different version of typeshed type stubs, specify the directory with this option.
|
||||
(2) This option is the same as the language server setting `python.pythonPath`. It cannot be used with --venvpath. The --pythonpath options is recommended over --venvpath in most cases. For more details, refer to the [import resolution](import-resolution.md#configuring-your-python-environment) documentation.
|
||||
|
||||
(3) This option is used in conjunction with configuration file, which can refer to different virtual environments by name. For more details, refer to the [configuration](configuration.md) documentation. This allows a common config file to be checked in to the project and shared by everyone on the development team without making assumptions about the local paths to the venv directory on each developer’s computer.
|
||||
(3) Pyright has built-in typeshed type stubs for Python stdlib functionality. To use a different version of typeshed type stubs, specify the directory with this option.
|
||||
|
||||
(4) When running in watch mode, pyright will reanalyze only those files that have been modified. These “deltas” are typically much faster than the initial analysis, which needs to analyze all files in the source tree.
|
||||
(4) This option is the same as the language server setting `python.venvPath`. It used in conjunction with configuration file, which can refer to different virtual environments by name. For more details, refer to the [configuration](configuration.md) and [import resolution](import-resolution.md#configuring-your-python-environment) documentation. This allows a common config file to be checked in to the project and shared by everyone on the development team without making assumptions about the local paths to the venv directory on each developer’s computer.
|
||||
|
||||
(5) When running in watch mode, pyright will reanalyze only those files that have been modified. These “deltas” are typically much faster than the initial analysis, which needs to analyze all files in the source tree.
|
||||
|
||||
|
||||
# Pyright Exit Codes
|
||||
|
@ -32,5 +32,5 @@ The Pyright language server honors the following settings.
|
||||
|
||||
**python.pythonPath** [path]: Path to Python interpreter. This setting is being deprecated by the VS Code Python extension in favor of a setting that is stored in the Python extension’s internal configuration store. Pyright supports both mechanisms but prefers the new one if both settings are present.
|
||||
|
||||
**python.venvPath** [path]: Path to folder with subdirectories that contain virtual environments.
|
||||
**python.venvPath** [path]: Path to folder with subdirectories that contain virtual environments. The `python.pythonPath` setting is recommended over this mechanism for most users. For more details, refer to the [import resolution](import-resolution.md#configuring-your-python-environment) documentation.
|
||||
|
||||
|
@ -136,6 +136,7 @@ async function processArgs(): Promise<ExitStatus> {
|
||||
{ name: 'level', type: String },
|
||||
{ name: 'outputjson', type: Boolean },
|
||||
{ name: 'project', alias: 'p', type: String },
|
||||
{ name: 'pythonpath', type: String },
|
||||
{ name: 'pythonplatform', type: String },
|
||||
{ name: 'pythonversion', type: String },
|
||||
{ name: 'skipunannotated', type: Boolean },
|
||||
@ -248,6 +249,18 @@ async function processArgs(): Promise<ExitStatus> {
|
||||
}
|
||||
}
|
||||
|
||||
if (args.pythonpath !== undefined) {
|
||||
const incompatibleArgs = ['venv-path', 'venvpath'];
|
||||
for (const arg of incompatibleArgs) {
|
||||
if (args[arg] !== undefined) {
|
||||
console.error(`'pythonpath' option cannot be used with '${arg}' option`);
|
||||
return ExitStatus.ParameterError;
|
||||
}
|
||||
}
|
||||
|
||||
options.pythonPath = combinePaths(process.cwd(), normalizePath(args['pythonpath']));
|
||||
}
|
||||
|
||||
if (args['venv-path']) {
|
||||
console.warn(`'venv-path' option is deprecated; use 'venvpath' instead`);
|
||||
options.venvPath = combinePaths(process.cwd(), normalizePath(args['venv-path']));
|
||||
@ -706,6 +719,7 @@ function printUsage() {
|
||||
' --outputjson Output results in JSON format\n' +
|
||||
' -p,--project <FILE OR DIRECTORY> Use the configuration file at this location\n' +
|
||||
' --pythonplatform <PLATFORM> Analyze for a specific platform (Darwin, Linux, Windows)\n' +
|
||||
' --pythonpath <FILE> Path to the Python interpreter\n' +
|
||||
' --pythonversion <VERSION> Analyze for a specific version (3.3, 3.4, etc.)\n' +
|
||||
' --skipunannotated Skip analysis of functions with no type annotations\n' +
|
||||
' --stats Print detailed performance stats\n' +
|
||||
|
Loading…
Reference in New Issue
Block a user