Deprecated command-line options 'typeshed-path' and 'venv-path' in favor of 'typeshedpath' and 'venvpath'. The hyphenated options were inconsistent with the conventions used for other options.

This commit is contained in:
Eric Traut 2023-05-13 15:56:26 -07:00
parent c51bb4b746
commit ba18f421d1
3 changed files with 20 additions and 8 deletions

View File

@ -17,8 +17,8 @@ Pyright can be run as either a VS Code extension or as a node-based command-line
| --pythonversion `<VERSION>` | Analyze for version (3.3, 3.4, etc.) |
| --skipunannotated | Skip type analysis of unannotated functions |
| --stats | Print detailed performance stats |
| -t, --typeshed-path `<DIRECTORY>` | Use typeshed type stubs at this location (2) |
| -v, --venv-path `<DIRECTORY>` | Directory that contains virtual environments (3) |
| -t, --typeshedpath `<DIRECTORY>` | Use typeshed type stubs at this location (2) |
| -v, --venvpath `<DIRECTORY>` | Directory that contains virtual environments (3) |
| --verbose | Emit verbose diagnostics |
| --verifytypes `<IMPORT>` | Verify completeness of types in py.typed package |
| --version | Print pyright version |

View File

@ -33,9 +33,9 @@ Pyright does not require a Python environment to be configured if all imports ca
Pyright uses the following mechanisms (in priority order) to determine which Python environment to use:
1. If a `venv` name is specified along with a `python.venvPath` setting (or a `--venv-path` command-line argument), it appends the venv name to the specified venv path.
1. If a `venv` name is specified along with a `python.venvPath` setting (or a `--venvpath` command-line argument), it appends the venv name to the specified venv path. This mechanism is not recommended for most users because it is less robust than the next two options because it relies on pyrights internal logic to determine the import resolution paths based on the virtual environment directories and files. The other two mechanisms (2 and 3 below) use the configured python interpreter to determine the import resolution paths (the value of `sys.path`).
2. If no `venv` is specified in the config file, use the `python.pythonPath` setting. This setting is defined by the VS Code Python extension and can be configured using the Python extensions environment picker interface. More recent versions of the Python extension no longer store the selected Python environment in the `python.pythonPath` setting and instead use a storage mechanism that is private to the extension. Pyright is able to access this through an API exposed by the Python extension.
2. Use the `python.pythonPath` setting. This setting is defined by the VS Code Python extension and can be configured using the Python extensions environment picker interface. More recent versions of the Python extension no longer store the selected Python environment in the `python.pythonPath` setting and instead use a storage mechanism that is private to the extension. Pyright is able to access this through an API exposed by the Python extension.
3. As a fallback, use the default Python environment (i.e. the one that is invoked when typing `python` in the shell).

View File

@ -140,8 +140,10 @@ async function processArgs(): Promise<ExitStatus> {
{ name: 'pythonversion', type: String },
{ name: 'skipunannotated', type: Boolean },
{ name: 'stats', type: Boolean },
{ name: 'typeshed-path', alias: 't', type: String },
{ name: 'venv-path', alias: 'v', type: String },
{ name: 'typeshed-path', type: String },
{ name: 'typeshedpath', alias: 't', type: String },
{ name: 'venv-path', type: String },
{ name: 'venvpath', alias: 'v', type: String },
{ name: 'verifytypes', type: String },
{ name: 'verbose', type: Boolean },
{ name: 'version', type: Boolean },
@ -247,13 +249,23 @@ async function processArgs(): Promise<ExitStatus> {
}
if (args['venv-path']) {
console.warn(`'venv-path' option is deprecated; use 'venvpath' instead`);
options.venvPath = combinePaths(process.cwd(), normalizePath(args['venv-path']));
}
if (args['venvpath']) {
options.venvPath = combinePaths(process.cwd(), normalizePath(args['venvpath']));
}
if (args['typeshed-path']) {
console.warn(`'typeshed-path' option is deprecated; use 'typeshedpath' instead`);
options.typeshedPath = combinePaths(process.cwd(), normalizePath(args['typeshed-path']));
}
if (args['typeshedpath']) {
options.typeshedPath = combinePaths(process.cwd(), normalizePath(args['typeshedpath']));
}
if (args.createstub) {
options.typeStubTargetImportName = args.createstub;
}
@ -697,8 +709,8 @@ function printUsage() {
' --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' +
' -t,--typeshed-path <DIRECTORY> Use typeshed type stubs at this location\n' +
' -v,--venv-path <DIRECTORY> Directory that contains virtual environments\n' +
' -t,--typeshedpath <DIRECTORY> Use typeshed type stubs at this location\n' +
' -v,--venvpath <DIRECTORY> Directory that contains virtual environments\n' +
' --verbose Emit verbose diagnostics\n' +
' --verifytypes <PACKAGE> Verify type completeness of a py.typed package\n' +
' --version Print Pyright version\n' +