24

When I am running via shell a pylint:

$ pylint decorator.py 
No config file found, using default configuration
************* Module decorator
C:  7, 0: Unnecessary parens after 'print' keyword (superfluous-parens)
C: 15, 0: Unnecessary parens after 'print' keyword (superfluous-parens)
C:  1, 0: Missing module docstring (missing-docstring)
C:  4, 0: Missing function docstring (missing-docstring)
C:  6, 4: Missing function docstring (missing-docstring)
C: 14, 0: Missing function docstring (missing-docstring)

However, as it can be seen below, these warning do not come up in VSCode

enter image description here

... despite the fact that some basic checking is indeed performed as it shown in the next picture where I have removed a blank line:

enter image description here

pkaramol
  • 16,451
  • 43
  • 149
  • 324
  • Based on "Unnecessary parens after 'print' keyword", your shell `pylint` is probably running in Python 2 – `print` is not a keyword in Python 3. – AKX Apr 17 '19 at 11:13
  • But I installed `pylint` via `pip3` : `sudo -HE pip3 install pylint` – pkaramol Apr 17 '19 at 11:18
  • @pkaramol Installing `pylint` via `python3 -m pip install pylint` (probably `sudo` needed) ensures that it will be installed in the correct environment (usually Python 3.x). – Joey Apr 17 '19 at 12:15

3 Answers3

39

Assuming you have configured Python's Extension correctly and you have Pylint installed,

VSCode's Python Extension will do minimal checking by default if you do not provide a Pylint configuration option.

Simply enter "python.linting.pylintUseMinimalCheckers": false, into your .vscode/settings.json to force this off.

This is how mine looks:

{
    "autoDocstring.docstringFormat": "numpy",
    "editor.minimap.enabled": false,
    "editor.selectionClipboard": false,
    "python.pythonPath": "/home/jim/anaconda3/envs/dipoleDisplay",
    "window.zoomLevel": 0,
    "terminal.integrated.rendererType": "dom",
    "python.linting.pylintUseMinimalCheckers": false,
}

after setting

lucasgcb
  • 1,028
  • 7
  • 15
  • 14
    This `python.linting.pylintUseMinimalCheckers` doesn't appear to exist anymore as of Feb. 2022 – it shows up as “Unknown Configuration Setting” in the json editor. – Soren Bjornstad Feb 23 '22 at 04:04
12

I had a similar problem where flake8 worked in VSCode but pylint didn't. Here are all the steps I had to check for pylint to start working:

  1. Your .vscode\settings.json file enables linting by pylint (this can be hand edited or by running these command palette commands: Python: Enable Linting and Python: Select Linter)

    "python.linting.enabled": true

    "python.linting.pylintEnabled": true

  2. from the command line (while in virtual environment) confirming that pylint and pylint-django are installed.

    pip show pylint

    pip show pylint-django

  3. Add a .pylintrc file to your root directory that includes these lines.

    [MASTER]

    load-plugins=pylint_django

(NOTE: you can replace this pylintrc file with the following line in settings.json.)

"python.linting.pylintArgs": ["--load-plugins", "pylint_django"]

For more info about using pylint in VSCode, see https://code.visualstudio.com/docs/python/linting#_pylint

For more info about the pylintrc file, see https://docs.pylint.org/en/1.6.0/run.html#command-line-options

Steve Nyholm
  • 806
  • 9
  • 9
  • This solution (install pylint and pylint_django) worked for me. My final settings.json ended up being a mix of the accepted and this answer. – Ruben Alves May 05 '21 at 00:01
  • 2
    Could you clarify why you use pylint_django, as opposed to say, just pylint? – GrayLiterature May 09 '21 at 18:40
  • 2
    NOTE: there is a step missing if you use the python extension. Verify that the selected environment (lower left) is the one that you want, and that has `pylint` installed. – SeF Nov 04 '21 at 14:18
1

I'm add json to my vscode project folder settings:

{
  ...
  "pylint.path": [
    "/home/username/.local/bin/pylint"
  ],
  "pylint.args": [
    "--rcfile=api/.pylintrc"
  ],
  ...
}

It working for me. My python files and .pylintrc file placed in ./api/ folder, which is subfolder of my project's root.

Sergio Belevskij
  • 2,478
  • 25
  • 24