Search code examples
pythonvisual-studio-codepylintpylance

How to define pylance linting arguments in VS Code (something like "python.linting.pylanceArgs")?


Until around 3 weeks ago, I'd been using pylint for linting my python-files in VS Code.

Then, I enabled pylance replacing pylint. Yet, pylance is not listed in the specific linter-list provided by VS Code.

Now, pylance doesn't show me unused module imports. I suspect this is not included in the default linting arguments of pylance, so I tried to find out how to modify them akin to the procedure of doing so with pylint, such as documented here and implemented like so (inserted into the settings.json - file of the current workspace):

"python.linting.pylintArgs": [
    "--max-line-length=80",
    "--disable=W0142,W0403,W0613,W0232,R0903,R0913,C0103,R0914,C0304,F0401,W0402,E1101,W0614,C0111,C0301"
]

How can I customize in a similar fashion the linting rules of pylance?


Solution

  • The python.linting.pylintArgs setting is for pylint only and is not used by pylance (as far as I know)

    It seems the setting you are looking for is this one python.analysis.diagnosticSeverityOverrides:

    {
        "python.analysis.diagnosticSeverityOverrides": {
            "reportUnusedImport": "information"
        }
    } 
    

    For the list of pylance settings you can visit this page and this one.