如何查看(或在 JSON 檔案中提取)VS Code 中 Python 診斷嚴重性規則的默認值,如此處所述?



您還可以檢查安裝在您機器上的 Pylance 擴展的目錄。首先,找到所有 VS Code 擴展的目錄:
擴展安裝在每個用戶的擴展檔案夾中。根據您的平臺,該位置位于以下檔案夾中:
- 視窗
%USERPROFILE%\.vscode\extensions- 蘋果系統
~/.vscode/extensions- Linux
~/.vscode/extensions
轉到該檔案夾??,然后查找該ms-python.vscode-pylance檔案夾。
.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
打開 package.json,在configuration> properties>下的某處python.analysis.diagnosticSeverityOverrides,您將找到所有這些規則及其默認值:
...
"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"
]
},
...
默認值在default密鑰中。(請注意reportMissingImportssettings.json 彈出視窗中螢屏截圖中的匹配項的默認值。
如果您需要將其提取為 JSON 格式,那已經是一個 JSON 檔案。
uj5u.com熱心網友回復:
C:\Users\{UserName}\.vscode\extensions\ms-python.vscode-pylance-2021.10.0\dist\schemas\pyrightconfig.schema.json
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/313996.html
