Skip to content

you accidentally made __init__ anti-linter #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kelvinwop opened this issue Oct 13, 2018 · 2 comments
Closed

you accidentally made __init__ anti-linter #131

kelvinwop opened this issue Oct 13, 2018 · 2 comments

Comments

@kelvinwop
Copy link

kelvinwop commented Oct 13, 2018

Expected behaviour

be detected by linter

Actual behaviour

not detected by linter

Steps to reproduce

  • install opencv-python
  • use vscode >extension microsoft python linter
  • try to use cv2 methods
  • RED SQUIGGLY LINES

I blame:

\cv2\__init__.py:

import importlib

from .cv2 import *
from .data import *

# wildcard import above does not import "private" variables like __version__
# this makes them available
globals().update(importlib.import_module('cv2.cv2').__dict__)

@skvark
Copy link
Member

skvark commented Oct 13, 2018

This seems to be a pylint issue. Add cv2 to the pylint extension package whitelist as suggested by this answer at Stack Overflow: https://stackoverflow.com/a/51916065/5795428

The wildcard import code in the __init__ file is perfectly valid Python. There's nothing "anti-linter" in the file. The last line is a bit hacky, but as the comment implies, it's needed to expose members which are ignored by the wildcard import.

I believe that the actual problem is related to the fact that the cv2 is binary extension module. For example Numpy behaves excatly the same way with pylint / vscode: https://stackoverflow.com/questions/20553551/how-do-i-get-pylint-to-recognize-numpy-members

@skvark skvark closed this as completed Oct 13, 2018
@kelvinwop
Copy link
Author

Strange. Seems to work with numpy lol.

Will add this link to the vscode issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants