question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pylint in vscode does not behave the same as command line

See original GitHub issue

Hello,

When running pylint within vscode, it does not behave the same as the command line version of pylint even though I have configured vscode to use the same settings file. Can you please help me understand why it differs and correct it?

Version Info

ms-python.python: v2020.8.108011

vscode:

Version: 1.49.0
Commit: e790b931385d72cf5669fcefc51cdf65990efa5d
Date: 2020-09-10T17:39:53.251Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 19.5.0

Python: 3.8.1 pylint: 2.6.0 Virtual environment: virtualenv

Settings

Here’s the relevant settings from my vscode settings.json:

  "python.pythonPath": "~/.pyenv/shims/python",
  "python.linting.pycodestylePath": "~/.pyenv/shims/pycodestyle",
  "python.linting.pylintPath": "~/.pyenv/shims/pylint",
  "python.linting.pylintUseMinimalCheckers": false,
  "python.linting.pylintArgs": [
    "--rcfile=setup.cfg"
  ],

My python setup.cfg is:

[pylint]
disable = W0703
max-line-length = 90

Results

When I run pylint from the command line, I get this:

$ pylint --rcfile=setup.cfg ssmpsm.py
************* Module ssmpsm
ssmpsm.py:131:0: C0301: Line too long (95/90) (line-too-long)
ssmpsm.py:163:0: C0301: Line too long (95/90) (line-too-long)
ssmpsm.py:181:0: C0301: Line too long (98/90) (line-too-long)
ssmpsm.py:152:4: R1703: The if statement can be replaced with 'var = bool(test)' (simplifiable-if-statement)
ssmpsm.py:147:0: R0912: Too many branches (14/12) (too-many-branches)

When pylint runs within vscode, it does not display R1703 and R0912 as per this screen shot:

Screen Shot 2020-09-12 at 22 14 51

If I change the max-line-length in setup.cfg, vscode does honour that setting in setup.cfg.

Expected Behaviour

I would expect vscode to behave the same way as the command line in with my current configuration.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
karthiknadigcommented, Sep 13, 2020

Do you have this setting checked or unchecked?: image

0reactions
karthiknadigcommented, Mar 18, 2022

We now have a new pylint extension (currently in pre-release) that provides greater control over some of the settings. It also runs in server mode so it should perform better in most scenarios. Please have a look https://marketplace.visualstudio.com/items?itemName=ms-python.pylint

With that extension you can control individual error codes if you need to like this:

{ 
    "convention": "Information", 
    "error": "Error", 
    "fatal": "Error", 
    "refactor": "Hint", 
    "warning": "Warning", 
    "info": "Information",
    "W0611": "Error", 
    "undefined-variable": "Warning"
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Linting Python in Visual Studio Code
Open a command prompt, navigate to the location where your selecter interpreter is, and run pip install for the linter.
Read more >
Disable errors in .pylintrc doesn't work in VS Code
For this, use the command line: cd into the directory in question and run pylint in verbose mode: pylint --verbose .
Read more >
Use PyLint for Python code - Visual Studio - Microsoft Learn
Run PyLint in Visual Studio to check issues in Python code, including command-line options to customize linting.
Read more >
Advanced Visual Studio Code for Python Developers
To assign a keybinding to a command that has no binding, double-click on it. If the key sequence you press is already assigned...
Read more >
2. Command Line Usage — prospector documentation
Often tools such as pylint find errors in code which is not an error, due to attributes of classes being created at run...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found