【发布时间】:2021-01-30 12:17:03
【问题描述】:
我已经在网上搜索了很长时间,但似乎无法找到解决我的问题的方法。我安装了 Pylance(最新的微软 Python interperter),似乎根本无法禁用 linting。我尝试了很多选择,但没有一个奏效。这是我的代码中令人讨厌的 linting 的屏幕截图。
这是我的 VSCode 设置文件的样子:
{
// "python.pythonPath": "C://Anaconda3//envs//py34//python.exe",
// "python.pythonPath": "C://Anaconda3_2020//python.exe",
// "python.pythonPath": "C://Anaconda3_2020_07//python.exe",
"python.pythonPath": "C://Anaconda3//python.exe",
"python.analysis.disabled": [
"unresolved-import"
],
"editor.suggestSelection": "first",
"editor.fontSize": 15,
"typescript.tsserver.useSeparateSyntaxServer": false,
"workbench.colorTheme": "Monokai ST3",
"workbench.colorCustomizations":{
"editor.background": "#000000",
"statusBar.background" : "#000000",
"statusBar.noFolderBackground" : "#212121",
"statusBar.debuggingBackground": "#263238"
},
"window.zoomLevel": 0,
"editor.renderLineHighlight": "none",
"editor.fontFamily": "Meslo LG L",
"editor.tabCompletion": "on",
"editor.parameterHints.enabled": true,
"python.terminal.executeInFileDir": true,
"python.terminal.launchArgs": [
"-u"
],
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"editor.lineHeight": 0,
"workbench.editor.scrollToSwitchTabs": true,
"python.autoComplete.showAdvancedMembers": false,
"python.languageServer": "Pylance",
"python.linting.enabled": false,
"python.linting.pylintEnabled": false,
"python.linting.lintOnSave": false,
"python.linting.flake8Enabled": false,
"python.linting.mypyEnabled": false,
"python.linting.banditEnabled": false,
"python.linting.pylamaEnabled": false,
"python.linting.pylintArgs": [
"--unsafe-load-any-extension=y",
"--load-plugin",
"pylint_protobuf",
"--disable=all",
"--disable=undefined-variable",
],
"python.linting.mypyArgs": [
"--ignore-missing-imports",
"--follow-imports=silent",
"--show-column-numbers",
"--extension-pkg-whitelist=all",
"--disable=all",
"--disable=undefined-variable",
],
}
有什么想法吗? 非常感谢任何帮助。
【问题讨论】:
-
Linting 对我们规范代码很有帮助。你介意告诉我们你为什么要关闭 Pylance 的 linting 吗?您能否为我们提供清晰的屏幕截图以查看掉毛的类型?
-
@JillCheng,感谢您的及时回复。不幸的是,鉴于文档中的专有信息,我无法分享详细的屏幕截图。我依靠文档的侧边栏概览进行快速搜索,将它们定位在文档的整体结构中。您在我链接的图像中看到的黄色高光说明了这些黄色高光可能有多烦人。这就是我需要关闭它的原因。
-
@JillCheng,感谢您的及时回复。我明白“黄色高亮”不会影响代码的执行。但是,在侧边栏中经常看到它们很快就会很烦人。我按照您的建议添加了 linting 选项,但这并没有解决问题。
-
-建议您尝试其他语言服务,例如:"python.languageServer":"Microsoft",
-
Linting 确实很有帮助,这就是为什么它应该成为部署管道的一部分,作为提交代码之前的最后检查。但是,编辑器中的 linting 很烦人。它不仅困扰我告诉我那些在定义上未完成的代码中不正确的事情,而且通常是错误的(例如,抱怨缺少导入)。我决定停止使用引入 Pylance 的 MS Python 扩展,因为我发现它太分散注意力了。
标签: python visual-studio-code lint pylint