25

I've been searching online for quite a while now and can't seem to find a solution for my problem. I installed Pylance (the newest Microsoft interpreter for Python) and can't seem to disable linting at all. I've tried a lot of options but none worked. Here's a screenshot of how annoying linting is in my code now.

Here's how my VSCode Settings file looks like:

{
    // "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",
    ],
}

enter image description here

Any thoughts? Any help is much appreciated.

S.B
  • 13,077
  • 10
  • 22
  • 49
TheNomad
  • 293
  • 1
  • 3
  • 10
  • Linting is very helpful for us to standardize the code. Do you mind letting us know why you want to turn off Pylance's linting? And could you provide us with a clear screenshot to view what type of linting is? – Jill Cheng Oct 16 '20 at 08:08
  • 2
    @JillCheng, Thank you for your prompt response. Unfortunately, I cannot share a detailed screenshot given the proprietary information within the document. I rely on the sidebar overview of the document for quick searches, locating them within a document's overall structure. The yellow highlights you see in the image I linked are an illustration of how annoying these yellow highlights could be. This brings the reason why I would need to turn it off. – TheNomad Oct 16 '20 at 13:02
  • -If there is no problem with the code, these "yellow highlights" do not affect the execution of the code. Based on the information you currently provide, it is recommended that you try to add "python.linting.pylintArgs" : [ "----extension-pkg-whitelist=1xml" ], in 'setting.json'. – Jill Cheng Oct 19 '20 at 01:27
  • 2
    @JillCheng, I appreciate you prompt response. I do understand that the "yellow highlights" do not affect the execution of the code. They are, though, quick annoying to constantly see in the sidebar. I added the linting options as you suggested but that did not solve the issue. – TheNomad Oct 19 '20 at 15:28
  • 1
    -It is recommended that you try other language services, for example: "python.languageServer":"Microsoft", – Jill Cheng Oct 20 '20 at 01:26
  • Thank you @JillCheng, I was able to remove the warnings by modifying some of the settings in the "python.analysis.diagnosticSeverityOverrides" arguments. – TheNomad Oct 20 '20 at 13:13
  • 5
    Linting is indeed helpful, which is why it should be part of the deployment pipeline, as a final check before committing code. However, linting in the editor is annoying. Not only does it bother me telling me about things that aren't right in code that is unfinished by definition, but it is often wrong (e.g. complaining about missing imports). I decided to stop using the MS Python extension with the introduction of Pylance as I found it too distracting. – cliff.wells May 13 '21 at 20:32
  • Plus, you should use open source linting tools like flake8 or pylint to ensure someone isn't lifting your possibly proprietary code. – DylanYoung Jun 24 '21 at 20:21
  • I use Flake8, then python extension install pylint with pylance, and I found kinda annoying have two of them. So in my case I want to stay with flake8(is the recommenden linter when i work). – Alejandro Ruiz Jun 24 '21 at 22:29
  • The need to turn it off is also compounded by the fact that Pylance is often fundamentally wrong in its diagnoses of type errors. It just stops you getting your stuff done while you go around looking for an error that does not exist. – Andrew S Oct 18 '22 at 04:10

4 Answers4

33

You can disable the language server with:

"python.languageServer": "None"
maxm
  • 3,412
  • 1
  • 19
  • 27
8

I was able to click on the Extensions within VSC, search for Pylance and then right click to uninstall. You can also disable.

bsdvs23
  • 119
  • 1
  • 4
5

Disabling language server works as answered by maxm. This will also disable other features.

Instead, just ignore the warnings and errors of pylance by setting below in settings.json of .vscode.

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

The other features will be present with out disabling pylance.

akhildevelops
  • 159
  • 1
  • 8
4

One way of getting rid of those warnings in your picture is to disable the Pylance by setting "python.languageServer": "None"(already mentioned by the accepted answer).

But you are basically disabling the language server which means you will lose all the help from Pylance. I don't think this is what you want.

Instead you can exclude some paths and those won't get type-checking at all. I usually do it for Python's standard library.

In previous versions of Pylance, you could create a pyrightconfig.json(Pylance is built on top of Pyright, that's why) in the root of your workspace and put this inside(for more information - click):

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

But since now (October 2022), you can directly set it in settings.json:

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

Remember you can use wild-cards in paths. This way your custom modules are only getting checked.

If you want to completely disable type-checking:

"python.analysis.typeCheckingMode": "off"
S.B
  • 13,077
  • 10
  • 22
  • 49