簡體   English   中英

無法完全禁用 python linting Pylance VSCODE

[英]Can't fully disable 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",
    ],
    "python.linting.mypyArgs": [
        "--ignore-missing-imports",
        "--follow-imports=silent",
        "--show-column-numbers",
        "--extension-pkg-whitelist=all",
        "--disable=all",
        "--disable=undefined-variable",
    ],
}

在此處輸入圖像描述

有什么想法嗎? 任何幫助深表感謝。

您可以通過以下方式禁用語言服務器:

"python.languageServer": "None"

fwiw:自動功能添加和更新只是最糟糕的事情,但絕對比任何其他選擇都好。

消除圖片中這些警告的一種方法是通過設置"python.languageServer": "None" (已被接受的答案提到)來禁用 Pylance。

但是您基本上是在禁用語言服務器,這意味着您將失去 Pylance 的所有幫助 我不認為這是你想要的。

相反,您可以排除一些路徑,而這些路徑根本不會進行類型檢查。 我通常為 Python 的標准庫這樣做。

在以前版本的 Pylance 中,您可以在工作區的根目錄中創建一個pyrightconfig.json (Pylance 建立在 Pyright 之上,這就是原因)並將其放入其中(有關更多信息 - 單擊):

{
    "ignore": [
        "path to your third-party package or stdlib or ..."
    ],
}

但是從現在( 2022年10月)開始,可以直接在settings.json中settings.json

"python.analysis.ignore": ["path to your third-party package or stdlib or ...", ]

請記住,您可以在路徑中使用通配符 這樣您的自定義模塊只會被檢查。

如果你想完全禁用類型檢查:

"python.analysis.typeCheckingMode": "off"

我能夠點擊 VSC 中的擴展,搜索 Pylance,然后右鍵單擊卸載。 您也可以禁用。

禁用語言服務器的工作方式由 maxm 回答。 這也將禁用其他功能。

相反,只需在 .vscode 的 settings.json 中進行如下設置,即可忽略 pylance 的警告和錯誤。

"python.analysis.ignore": [
        "*"
    ]

其他功能將在不禁用 pylance 的情況下出現。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM