August 17, 2020

Visual Studio Code PyLint issue

Problem: For Visual Studio Code, valid Python code has red-squiggles.


Visual Studio Code is a great tool for python programming.  Recently, I found a strange issue: a valid python code line has red squiggles.  It is a method call of some package I installed, and VSC correctly pops up available methods for the package fine.  It's there, why red squiggle then?

This red squiggle is work of Linting telling me that something is wrong.  VSC supports different Lint programs, and PyLint is one of them that works for me the best. 

But this red squiggle for valid method -- this turns out to be a security feature: Pylint does not import non-stdlib C extensions as it is a security risk.



Tell Pylint to load the extension anyways.

1. File → Preferences → Settings → User settings tab

2. Type in "python.linting.pylintArgs"  This will bring up Pylint Argument setting.

3. Click on "Add Item" button and add this line:


All working well now.

ADDITION - Disable warnings


$ pylint --generate-rcfile > stndard.rc 

In [MESSAGES CONTROL], and check/add messages to disable:


Add this as an argument --rcfile="...standard.rc"

[2] Within VSC

In preferences, add:

"python.linting.pylintArgs": ["--errors-only"]


No comments: