7
votes

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"
    ]
}
3
Have you tried to do ctrl+shift+p i guess cmd+shift+p on Mac and then write select linter. It should display you a list of the linter installed, if pylint is not installed you can do it with pip pip install pylint or conda conda install -c anaconda pylintNinii
I used the commands already: select linter, enable linter, run linter, and nothing happens.atlau
Have you checked your settings like the ctrl+shift+p settings both (json) and (ui) and see there if everything is configured normallyNinii
you can try to add "python.linting.pylintEnabled": true in your settings.json fileNinii
Yes I have that in settings.json, and "python.linting.pylintEnabled": true,atlau

3 Answers

3
votes

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!

0
votes

I had the same issue, but resolved it after installing the cornflakes-linter for VS code.

-1
votes

Perhaps one possible solution could be launching the VS Code from the terminal/cmd.

These are the steps to enable you to launch the VS Code from the terminal (macOS), from the VS code site.

For installation:

  1. Download Visual Studio Code for macOS.
  2. Open the browser's download list and locate the downloaded archive.
  3. Select the 'magnifying glass' icon to open the archive in Finder.
  4. Drag Visual Studio Code.app to the Applications folder, making it available in the macOS Launchpad.
  5. Add VS Code to your Dock by right-clicking on the icon to bring up the context menu and choosing Options, Keep in Dock.

Launching from the command line:

  1. Launch VS Code.
  2. Open the Command Palette (⇧⌘P) and type shell command to find the Shell Command: Install 'code' command in PATH command.
  3. Restart the terminal for the new $PATH value to take effect. You'll be able to type code . in any folder to start editing files in that folder.

Launching the VS Code from the command line in venv:

  1. Activating venv in your terminal/command line, for my case, I use source activate venv
  2. Launch VS Code after the activation of venv, using code . in the desired directory.

For Windows and Linux, the steps to set up the path can be found in the links.