Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pylint not running as expected in VScode

Tags:

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

like image 803
pkaramol Avatar asked Apr 17 '19 11:04

pkaramol


People also ask

Why is Pylint not working in VSCode?

The problem mostly happens in Linux. You need to make sure pylint is installed in the same environment that VSCode detects. This may be the problem! Open up a terminal and run pip --version , it will tell you the current version of pip and python associated with pip .

How do I run a Pylint code in Visual Studio?

To perform linting, open the Command Palette (Ctrl+Shift+P), filter on "linting", and select Python: Run Linting. Linting will run automatically when you save a file.

How do I know if Pylint is installed?

First, to check the version of Pylint you're running, run the following command: pylint --version.


2 Answers

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

like image 108
lucasgcb Avatar answered Sep 21 '22 05:09

lucasgcb


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

like image 37
Steve Nyholm Avatar answered Sep 19 '22 05:09

Steve Nyholm