mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Renamed setting "pyright.useLibraryCodeForTypes" to "python.analysis.useLibraryCodeForTypes" for compatibility with Pylance. The older setting name is still supported but will be removed in the future.
This commit is contained in:
parent
3581910469
commit
0cb83d36c8
@ -138,6 +138,12 @@
|
||||
"description": "Paths to look for typeshed modules.",
|
||||
"scope": "resource"
|
||||
},
|
||||
"python.analysis.useLibraryCodeForTypes": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Use library implementations to extract type information when type stub is not present.",
|
||||
"scope": "resource"
|
||||
},
|
||||
"pyright.disableLanguageServices": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
@ -156,12 +162,6 @@
|
||||
"description": "Path to Python, you can use a custom version of Python.",
|
||||
"scope": "resource"
|
||||
},
|
||||
"pyright.useLibraryCodeForTypes": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Use library implementations to extract type information when type stub is not present.",
|
||||
"scope": "resource"
|
||||
},
|
||||
"python.venvPath": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
|
@ -5,7 +5,7 @@ A static type checker like Pyright can add incremental value to your source code
|
||||
Here is a typical progression:
|
||||
1. Install pyright (either the VS Code extension or command-line tool).
|
||||
2. Write a minimal `pyrightconfig.json` that defines `include` entries. Place the config file in your project’s top-level directory and commit it to your repo.
|
||||
3. Optionally enable the `pyright.useLibraryCodeForTypes` config option (or pass `--libs` to the command-line tool). This tells Pyright that it should attempt to infer type information from library code if a type stub is not available.
|
||||
3. Optionally enable the `python.analysis.useLibraryCodeForTypes` config option (or pass `--libs` to the command-line tool). This tells Pyright that it should attempt to infer type information from library code if a type stub is not available.
|
||||
4. Run pyright over your source base with the default settings. Fix any errors and warnings that it emits.
|
||||
5. Enable the `reportMissingTypeStubs` setting in the config file and add (minimal) type stub files for the imported files. You may wish to create a stubs directory within your code base — a location for all of your custom type stub files. Configure the “stubPath” config entry to refer to this directory.
|
||||
6. Look for type stubs for the packages you use. Some package authors opt to ship stubs as a separate companion package named that has “-stubs” appended to the name of the original package.
|
||||
|
@ -24,7 +24,7 @@ For absolute (non-relative) imports, Pyright employs the following resolution or
|
||||
|
||||
5. Try to resolve using a **third-party typeshed** stub. If the `typeshedPath` is configured, use this instead of the typeshed stubs that are packaged with Pyright. This allows for the use of a newer or a patched version of the typeshed third-party stubs.
|
||||
|
||||
6. If the `pyright.useLibraryCodeForTypes` is set to true (or the `--lib` command-line argument was specified), try to resolve using the **library implementation** (“.py” file). Some “.py” files may contain partial or complete type annotations. Pyright will use type annotations that are provided and do its best to infer any missing type information. If you are using Pyright, `pyright.useLibraryCodeForTypes` is false by default. If you are using Pylance, it is true.
|
||||
6. If the `python.analysis.useLibraryCodeForTypes` setting is set to true (or the `--lib` command-line argument was specified), try to resolve using the **library implementation** (“.py” file). Some “.py” files may contain partial or complete type annotations. Pyright will use type annotations that are provided and do its best to infer any missing type information. If you are using Pyright, `python.analysis.useLibraryCodeForTypes` is false by default. If you are using Pylance, it is true.
|
||||
|
||||
|
||||
|
||||
|
@ -8,12 +8,14 @@ The Pyright VS Code extension honors the following settings.
|
||||
|
||||
**pyright.openFilesOnly** [boolean]: Determines whether pyright analyzes (and reports errors for) all files in the workspace, as indicated by the config file. If this option is set to true, pyright analyzes only open files. This setting is deprecated in favor of python.analysis.diagnosticMode. It will be removed at a future time.
|
||||
|
||||
**pyright.useLibraryCodeForTypes** [boolean]: Determines whether pyright reads, parses and analyzes library code to extract type information in the absence of type stub files. Type information will typically be incomplete. We recommend using type stubs where possible. The default value for this option is false.
|
||||
|
||||
**python.analysis.typeshedPaths** [array of paths]: Paths to look for typeshed modules. Pyright currently honors only the first path in the array.
|
||||
**pyright.useLibraryCodeForTypes** [boolean]: This setting is deprecated in favor of python.analysis.useLibraryCodeForTypes. It will be removed at a future time.
|
||||
|
||||
**python.analysis.autoSearchPaths** [boolean]: Determines whether pyright automatically adds common search paths like "src" if there are no execution environments defined in the config file.
|
||||
|
||||
**python.analysis.diagnosticMode** ["openFilesOnly", "workspace"]: Determines whether pyright analyzes (and reports errors for) all files in the workspace, as indicated by the config file. If this option is set to "openFilesOnly", pyright analyzes only open files.
|
||||
|
||||
**python.analysis.diagnosticSeverityOverrides** [map]: Allows a user to override the severity levels for individual diagnostic rules. "reportXXX" rules in the type check diagnostics settings in [configuration](https://github.com/microsoft/pyright/blob/master/docs/configuration.md#type-check-diagnostics-settings) are supported. Use the rule name as a key and one of "error," "warning," "information," "true," "false," or "none" as value.
|
||||
|
||||
**python.analysis.extraPaths** [array of paths]: Paths to add to the default execution environment extra paths if there are no execution environments defined in the config file.
|
||||
|
||||
**python.analysis.logLevel** ["error", "warning", "info", or "trace"]: Level of logging for Output panel. The default value for this option is "info".
|
||||
@ -22,9 +24,9 @@ The Pyright VS Code extension honors the following settings.
|
||||
|
||||
**python.analysis.typeCheckingMode** ["off", "basic", "strict"]: Determines the default type-checking level used by pyright. This can be overridden in the configuration file. (Note: This setting used to be called "pyright.typeCheckingMode". The old name is deprecated but is still currently honored.)
|
||||
|
||||
**python.analysis.diagnosticMode** ["openFilesOnly", "workspace"]: Determines whether pyright analyzes (and reports errors for) all files in the workspace, as indicated by the config file. If this option is set to "openFilesOnly", pyright analyzes only open files.
|
||||
**python.analysis.typeshedPaths** [array of paths]: Paths to look for typeshed modules. Pyright currently honors only the first path in the array.
|
||||
|
||||
**python.analysis.diagnosticSeverityOverrides** [map]: Allows a user to override the severity levels for individual diagnostic rules. "reportXXX" rules in the type check diagnostics settings in [configuration](https://github.com/microsoft/pyright/blob/master/docs/configuration.md#type-check-diagnostics-settings) are supported. Use the rule name as a key and one of "error," "warning," "information," "true," "false," or "none" as value.
|
||||
**python.analysis.useLibraryCodeForTypes** [boolean]: Determines whether pyright reads, parses and analyzes library code to extract type information in the absence of type stub files. Type information will typically be incomplete. We recommend using type stubs where possible. The default value for this option is false.
|
||||
|
||||
**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.
|
||||
|
||||
|
@ -101,6 +101,10 @@ class PyrightServer extends LanguageServerBase {
|
||||
serverSettings.openFilesOnly = !!pythonAnalysisSection.openFilesOnly;
|
||||
}
|
||||
|
||||
if (pythonAnalysisSection.useLibraryCodeForTypes !== undefined) {
|
||||
serverSettings.useLibraryCodeForTypes = !!pythonAnalysisSection.useLibraryCodeForTypes;
|
||||
}
|
||||
|
||||
serverSettings.logLevel = this.convertLogLevel(pythonAnalysisSection.logLevel);
|
||||
serverSettings.autoSearchPaths = !!pythonAnalysisSection.autoSearchPaths;
|
||||
|
||||
@ -122,7 +126,10 @@ class PyrightServer extends LanguageServerBase {
|
||||
serverSettings.openFilesOnly = !!pyrightSection.openFilesOnly;
|
||||
}
|
||||
|
||||
if (pyrightSection.useLibraryCodeForTypes !== undefined) {
|
||||
serverSettings.useLibraryCodeForTypes = !!pyrightSection.useLibraryCodeForTypes;
|
||||
}
|
||||
|
||||
serverSettings.disableLanguageServices = !!pyrightSection.disableLanguageServices;
|
||||
serverSettings.disableOrganizeImports = !!pyrightSection.disableOrganizeImports;
|
||||
if (pyrightSection.typeCheckingMode !== undefined) {
|
||||
|
Loading…
Reference in New Issue
Block a user