How do I enable Pylint in VSCode?

33,928

Solution 1

Simplest way using UI:

  1. Press "Ctrl + Shift + P" to get Command Palette
  2. Type "Lint"

enter image description here

  1. Select "Python : Enable/Disable Linting", click on "Enable"
  2. Repeat Step 1 & 2, now select "Python : Select Linter", Select pylint from options

enter image description here

  1. Above steps will add below lines in "settings.json" under .vscode dir

enter image description here

Solution 2

As this post suggests, this is currently fixed: https://github.com/microsoft/vscode-python/issues/12285#issuecomment-649350148

My .vscode/settings.json:

{
    "python.linting.enabled": true,
    "python.linting.pylintEnabled": true,
    "python.languageServer": "Microsoft"
}

It should work both on Jedi and Microsoft servers. Cheers!

Share:
33,928
atlau
Author by

atlau

Updated on July 11, 2022

Comments

  • atlau
    atlau almost 2 years

    I can't get pylint errors to show up in VSCode. I installed pylint globally (sudo apt install pylint), I created venv and installed it there with pip, I selected pylint as linter in VSCode, enabled it, ran it, and it doesnt show any errors in my file. If I check from the command line, it shows many errors in my file.

    This was working earlier, but not now on VSCode version 1.46.1 and 1.45.1 installed using snap.

    Same results with the Microsoft and the Jedi python language server.

    I found the pylint command in the developer console:

    ~/Documents/work/python/.venv/bin/python ~/.vscode/extensions/ms-python.python-2020.6.89148/pythonFiles/pyvsc-run-isolated.py pylint --disable=all --enable=F,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,unused-wildcard-import,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0107,E0108,E0110,E0111,E0112,E0113,E0114,E0115,E0116,E0117,E0118,E0202,E0203,E0211,E0213,E0236,E0237,E0238,E0239,E0240,E0241,E0301,E0302,E0303,E0401,E0402,E0601,E0602,E0603,E0604,E0611,E0632,E0633,E0701,E0702,E0703,E0704,E0710,E0711,E0712,E1003,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701 --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text ~/Documents/work/python/micro.py 
    

    So pylint is indeed executed! If I run it like this from the command line, the output is:

    Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
    

    But if I execute pylint micro.py I get:

    Your code has been rated at -2.50/10 (previous run: 10.00/10, -12.50)
    

    Why is VSCode using that command line? I am testing now without a .pylintrc, but even when I had it, VSCode showed no errors, only the command line! However I just tried it again, added a .pylintrc and now the errors do show up in the editor for some reason!

    But this is only with the Jedi server, when trying with the Microsoft server, linting cannot be enabled with its command, nothing happens and it stays off.

    My .vscode/settings.json:

    {
        "python.linting.pylintEnabled": true,
        "python.linting.enabled": true,
        "python.linting.pylintArgs": [
            "--rcfile",
            "${workspaceFolder}/backend/.pylintrc"
        ]
    }
    
  • atlau
    atlau almost 4 years
    No this does not make any difference.
  • Jan Pi
    Jan Pi over 2 years
    it's a different linter, though