无法完全禁用 python linting Pylance VSCODE

我已经在网上搜索了很长一段时间,似乎无法找到解决我的问题的方法。我安装了 Pylance(最新的 Microsoft Python 解释器),但似乎根本无法禁用 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",

    ],

}

https://i.stack.imgur.com/DIryp.png

有什么想法吗?任何帮助深表感谢。



红糖糍粑
浏览 120回答 4
4回答

米脂

您可以通过以下方式禁用语言服务器:"python.languageServer": "None"

慕田峪4524236

禁用语言服务器的工作原理如 maxm 所回答。这也将禁用其他功能。相反,只需在 .vscode 的 settings.json 中进行以下设置,即可忽略 pylance 的警告和错误。"python.analysis.ignore": [        "*"    ]其他功能将在不禁用 pylance 的情况下出现。

郎朗坤

我可以单击 VSC 中的扩展,搜索 Pylance,然后右键单击卸载。您也可以禁用。

海绵宝宝撒

消除图片中这些警告的一种方法是通过设置禁用 Pylance "python.languageServer": "None"(已在接受的答案中提到)。但您基本上禁用了语言服务器,这意味着您将失去Pylance 的所有帮助。我认为这不是你想要的。相反,您可以排除某些路径,而这些路径根本不会进行类型检查。我通常为Python的标准库做这件事。在以前版本的 Pylance 中,您可以在工作区的根目录中创建一个pyrightconfig.json(Pylance 是在 Pyright 之上构建的,这就是原因)并将其放入其中(有关更多信息 -单击):{     "ignore": [         "path to your third-party package or stdlib or ..."     ],}但从现在( 2022年10月)开始,你可以直接设置为settings.json:"python.analysis.ignore": ["path to your third-party package or stdlib or ...", ]请记住,您可以在 paths 中使用通配符。这样您的自定义模块只会被检查。如果你想完全禁用类型检查:"python.analysis.typeCheckingMode": "off"
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python