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 pkgwhitelist working

See original GitHub issue

Environment data

  • VS Code version: 1.29.1
  • Extension version (available under the Extensions sidebar): 2018.11.0
  • OS and version: Windows 10 Pro, Build 17134
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.0 Anaconda 4.5.11
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): N/A + conda
  • Relevant/affected Python packages and their versions: pylint 2.2.2

Expected behaviour

When calling pylint test.py --extension-pkg-whitelist=cv2 with test.py looking like so:

import cv2

cv2.imshow()

I obtain the output:

************* Module test
test.py:3:0: C0304: Final newline missing (missing-final-newline)
test.py:1:0: C0111: Missing module docstring (missing-docstring)

Actual behaviour

Trying the same in vscode with settings.json as:

{
    "python.linting.pylintArgs": ["--extension-pkg-whitelist=cv2"]
}

yields in the Python Output:

##########Linting Output - pylint##########
************* Module test
3,0,convention,C0304:Final newline missing
1,0,convention,C0111:Missing module docstring
3,0,error,E1101:Module 'cv2' has no 'imshow' member

Strangely, when changing settings.json to:

{
    "python.linting.pylintArgs": ["--version"]
}

the output is

##########Linting Output - pylint##########
__main__.py 2.2.2
astroid 2.0.4
Python 3.7.0 (default, Jun 28 2018, 08:04:48) [MSC v.1912 64 bit (AMD64)]

The developer console doesn’t seem to give any helpful output.

To fix this I’ve tried completely a complete reinstall of vscode (including removing all extensions and clearing the cache), as well as using the base conda and a complete fresh conda environment. The last thing that would come to mind is an issue with Anaconda, but I’d like to refrain from a fresh Anaconda install if possible.

EDIT: Also holds for torch, so it is not just a cv2 module specific problem but an issue for any dynamically loaded (is this the correct term?) module.

EDIT 2: Didn’t have access to my desktop the last couple of days, but now that I do have access, I am unable to reproduce the issue there. Linting works perfectly fine for both cv2 and torch.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
fschlattcommented, Dec 13, 2018

Ok, I’ll update the issue if a find a solution.

0reactions
brettcannoncommented, Dec 12, 2018

I’m going to assume it’s an odd Pylint issue or a hard-to-diagnose environment issue then since we don’t filter arguments to Pylint so this wouldn’t be caused by us explicitly.

One other option is to try using a .pylintrc file instead of command-line flag to see if that changes things for some reason.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pylint extension-pkg-whitelist=cv2 not working only when ...
If I set argument "python.linting.pylintArgs": ["--extension-pkg-whitelist=cv2"] , the linter should look up members in the cv2 ...
Read more >
How do I get Pylint to recognize NumPy members?
Then open the file and add the packages you want after extension-pkg-whitelist= separated by comma. You can have the same behavior using the ......
Read more >
Pylint and C extensions — Pylint 2.3.1 documentation
But pylint actually has a mechanism which you might use in case you want to analyze C extensions. pylint has a flag, called...
Read more >
Pylint features — Pylint 1.5.4 documentation
Extensions are imported into the active Python interpreter and may run arbitrary code. extension-pkg-whitelist: A comma-separated list of package or module ...
Read more >
Pylint configuration - CodeFlow
.pylintrc ; extension-pkg-whitelist · # Add files or directories to the blacklist. They should be base names, not # paths. ; ignore ·...
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