visual-studio-code - 如何在 VS Code 中查看 Python 诊断严重性规则的默认值?
问题描述
如此处所述,如何查看(或在 JSON 文件中提取)VS Code 中 Python 的诊断严重性规则的默认值? https://github.com/microsoft/pylance-release/blob/main/DIAGNOSTIC_SEVERITY_RULES.md#diagnostic-severity-rules
解决方案
如果您只需要查看 VS Code 中的默认值,只需打开 settings.json 文件(用户或工作区),然后一一输入其中的每个键。每个可能的值都应该出现一个弹出窗口,默认值将在描述中带有“默认值”提示。
您还可以检查机器上安装的 Pylance 扩展目录。首先,找到所有 VS Code 扩展的目录:
扩展安装在每个用户的扩展文件夹中。根据您的平台,该位置位于以下文件夹中:
- 视窗
%USERPROFILE%\.vscode\extensions
- 苹果系统
~/.vscode/extensions
- Linux
~/.vscode/extensions
转到该文件夹,然后查找该ms-python.vscode-pylance*
文件夹。
$ cd ~/.vscode/extensions/
extensions$ tree . -L 1 | grep "ms-python.vscode-pylance"
├── ms-python.vscode-pylance-2021.10.0
extensions$ cd ms-python.vscode-pylance-2021.10.0
ms-python.vscode-pylance-2021.10.0$ tree -L 1 .
.
├── CHANGELOG.md
├── LICENSE.txt
├── NOTICE.txt
├── README.md
├── dist
├── images
├── package.json
├── package.nls.json
└── package.nls.ru.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
键中。(请注意,与 settings.json 弹出窗口中的屏幕截图中的默认reportMissingImports
匹配。
如果您需要将其提取为 JSON 格式,那已经是一个 JSON 文件。
推荐阅读
- java - 使用 Part 类 jsp 编译 FileUpload servlet 时找不到符号
- scala - Spark 提交作业在本地模式下失败且没有错误
- database - 尝试将 csv 文件中的数据插入 accdb 表时出现问题
- csv - 使用胶水将巨大的 CSV 转换为带有分区的 Parquet
- mysql - MySQL慢查询日志空提交
- c# - unity 字符跳跃和下降超过我输入的值
- git - 暂时禁用 github Webhook
- cypress - 用于类似数组的 prevSubject 的赛普拉斯自定义命令
- java - Maven获取最新的依赖
- android - RelativeLayout 中不能存在循环依赖关系 - 为什么?