Home > Net >  How can I see the default values for the Python Diagnostic Severity Rules in VS Code?
How can I see the default values for the Python Diagnostic Severity Rules in VS Code?

Time:10-16

How can I see (or extract in a JSON file) the default values for the Diagnostic Severity Rules for Python in VS Code, as described here? settings UI

enter setting

see default value hint

You can also check the Pylance extension's directory installed on your machine. First, find the directory for all your VS Code extensions:

Extensions are installed in a per user extensions folder. Depending on your platform, the location is in the following folder:

  • Windows %USERPROFILE%\.vscode\extensions
  • macOS ~/.vscode/extensions
  • Linux ~/.vscode/extensions

Go to that folder, and look for the ms-python.vscode-pylance folder.

.vscode$ ls extensions | grep ms-python.vscode-pylance*
ms-python.vscode-pylance-2021.10.0

.vscode$ ls extensions/ms-python.vscode-pylance*
CHANGELOG.md        NOTICE.txt          dist                package.json        package.nls.ru.json
LICENSE.txt         README.md           images              package.nls.json

Open the package.json, and somewhere under configuration > properties > python.analysis.diagnosticSeverityOverrides, you'll find all those rules with their default values:

...
"reportMissingImports": {
    "type": "string",
    "description": "Diagnostics for imports that have no corresponding imported python file or type stub file.",
    "default": "warning",
    "enum": [
            "none",
            "information",
            "warning",
            "error"
    ]
},
"reportMissingModuleSource": {
    "type": "string",
    "description": "Diagnostics for imports that have no corresponding source file. This happens when a type stub is found, but the module source file was not found, indicating that the code may fail at runtime when using this execution environment. Type checking will be done using the type stub.",
    "default": "warning",
    "enum": [
            "none",
            "information",
            "warning",
            "error"
    ]
},
"reportMissingTypeStubs": {
    "type": "string",
    "description": "Diagnostics for imports that have no corresponding type stub file (either a typeshed file or a custom type stub). The type checker requires type stubs to do its best job at analysis.",
    "default": "warning",
    "enum": [
            "none",
            "information",
            "warning",
            "error"
    ]
},
...

The default value is in the default key. (Notice the default for reportMissingImports matches the one in the screenshot from the settings.json popup.

That's already a JSON file, if you need to extract it to JSON format.

CodePudding user response:

C:\Users\{UserName}\.vscode\extensions\ms-python.vscode-pylance-2021.10.0\dist\schemas\pyrightconfig.schema.json
  • Related