Skip to content
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

generated-memberoption is not properly documented #7944

Closed
Chris-fullerton opened this issue Dec 15, 2022 · 4 comments · Fixed by #7949
Closed

generated-memberoption is not properly documented #7944

Chris-fullerton opened this issue Dec 15, 2022 · 4 comments · Fixed by #7949
Assignees

Comments

@Chris-fullerton
Copy link

Bug description

I tried to use pylint in Google Python Style Guide, but I couldn't enhance my score of pylint because tons of no-member / E1101 especially cv2.

I have already read no-member / E1101 and tried all solutions, but didn't work.


After some logging(simply print), .../python3.8/site-package/pylint/lint/run.py[137:141+1]:

        # Determine configuration file
        if self._rcfile is None:
            default_file = next(config.find_default_config_files(), None)
            if default_file:
                self._rcfile = str(default_file)
        print(self._rcfile) # to check whether pylint get ~/.pylintrc correctly

and run pylint test.py, I got this:

/Users/[myUserID]/.pylintrc
************* Module test
test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test.py:3:6: E1101: Module 'cv2' has no 'LINE_AA' member (no-member)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

seems that pylint get the correct rcfile, but no-member / E1101 still appears after I change these in ~/.pylintrc one by one:

extension-pkg-allow-list=cv2
extension-pkg-whitelist=cv2
unsafe-load-any-extension=yes
disable=c-extension-no-member

still got this from pylint test.py:

************* Module test
test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test.py:3:6: E1101: Module 'cv2' has no 'LINE_AA' member (no-member)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Test code(test.py):

import cv2

print(cv2.LINE_AA)

Simply run(python test.py), to make sure this code is runnable:

16

Installed(conda list | grep 'pylint\|cv'):

opencv-python-headless    4.6.0.66                 pypi_0    pypi
pylint                    2.15.8                   pypi_0    pypi

More Info(which python):

python: aliased to python3

Configuration

extension-pkg-allow-list=cv2
extension-pkg-whitelist=cv2
unsafe-load-any-extension=yes

# wrote in https://pylint.pycqa.org/en/latest/user_guide/messages/error/no-member.html#no-member-e1101
unsafe-load-any-extension=y

disable=c-extension-no-member

Command used

[1] pylint test.py
[2] pylint --extension-pkg-allow-list=cv2 test.py
[3] pylint --extension-pkg-whitelist=cv2 test.py
[4] pylint --unsafe-load-any-extension=yes test.py
[5] pylint --unsafe-load-any-extension=y test.py
[6] pylint --disable=c-extension-no-member test.py

Pylint output

all commands above got:

************* Module test
test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test.py:3:6: E1101: Module 'cv2' has no 'LINE_AA' member (no-member)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Expected behavior

pylint can recognize cv2 and other c-package correctly, instead of poping no-member / E1101.

Pylint version

pylint 2.15.8
astroid 2.12.13
Python 3.8.15 | packaged by conda-forge | (default, Nov 22 2022, 08:49:06)
[Clang 14.0.6 ]

OS / Environment

macOS Ventura 13.0, Apple M1
iTerm, zsh

Additional dependencies

albumentations==1.3.0
astroid==2.12.13
certifi==2022.9.24
charset-normalizer==2.1.1
coloredlogs==15.0.1
contourpy==1.0.6
cycler==0.11.0
Cython==0.29.32
dill==0.3.6
easydict==1.10
<- my personal private github python package url
flatbuffers==22.12.6
fonttools==4.38.0
humanfriendly==10.0
idna==3.4
imageio==2.22.4
insightface==0.6.2
isort==5.11.1
joblib==1.2.0
kiwisolver==1.4.4
lazy-object-proxy==1.8.0
matplotlib==3.6.2
mccabe==0.7.0
mpmath==1.2.1
networkx==2.8.8
numpy==1.23.4
onnx==1.12.0
onnxruntime==1.13.1
onnxruntime-silicon==1.11.1
opencv-python-headless==4.6.0.66
packaging==21.3
Pillow==9.3.0
platformdirs==2.6.0
prettytable==3.5.0
protobuf==3.20.1
pylint==2.15.8
pynput==1.7.6
pyobjc-core==9.0
pyobjc-framework-ApplicationServices==9.0
pyobjc-framework-Cocoa==9.0
pyobjc-framework-Quartz==9.0
pyparsing==3.0.9
python-dateutil==2.8.2
PyWavelets==1.4.1
PyYAML==6.0
qudida==0.0.4
requests==2.28.1
scikit-image==0.19.3
scikit-learn==1.1.3
scipy==1.9.3
six==1.16.0
sympy==1.11.1
threadpoolctl==3.1.0
tifffile==2022.10.10
tomli==2.0.1
tomlkit==0.11.6
tqdm==4.64.1
typing_extensions==4.4.0
urllib3==1.26.13
wcwidth==0.2.5
wrapt==1.14.1

@Chris-fullerton Chris-fullerton added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Dec 15, 2022
@Pierre-Sassoulas
Copy link
Member

Could you try the generated-member option ? It's not documented in https://pylint.pycqa.org/en/latest/user_guide/messages/error/no-member.html which is bad and we need to fix that.

@Pierre-Sassoulas Pierre-Sassoulas added Documentation 📗 and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Dec 15, 2022
@Chris-fullerton
Copy link
Author

Could you try the generated-member option ?

It works well with commend argument like this pylint --generated-member=cv2 test.py and~/.pylintrc, thanks for this solution.

By the way, have I done any wrong operation above? Why extension-pkg-allow-list not work anymore for me?

@Pierre-Sassoulas
Copy link
Member

Pierre-Sassoulas commented Dec 15, 2022

By default C extensions are not loaded into the active Python interpreter (they may run arbitrary code). The extension-pkg-allow-list option permit to load and parse them, however it doesn't mean that pylint will understand everything in it (especially with dynamic generation of attribute or function).

By the way you should use pylint --generated-member=cv2.LINE_AA because otherwise pylint will become useless on cv2.whatever_mistake

@Pierre-Sassoulas Pierre-Sassoulas self-assigned this Dec 15, 2022
@Pierre-Sassoulas Pierre-Sassoulas changed the title cv2 module members are not recognized(tried: ~/.pylintrc, --extension-pkg-allow-list=cv2) generated-memberoption is not properly documented Dec 15, 2022
@Chris-fullerton
Copy link
Author

Actually I have already found that pylint knows cv2.VideoCapture() before, but didn't know cv2.LINE_AA and some others var of cv2. Now I finally understand what happend before. Thanks for solving my questions.

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

Successfully merging a pull request may close this issue.

2 participants