Skip to content

Pylint no-member warnings in 4.5.4.58 #570

Closed

Description

@robertschweizer

Expected behaviour

Pylint was previously able to inspect cv2 member existence with the extension-pkg-whitelist parameter.

Actual behaviour

For opencv-python-4.5.4.58, pylint can no longer inspect the members.

Steps to reproduce

On Windows 10, Python 3.8 64bit, using Pylint 2.11.1:

"""Test module test.py"""
from cv2 import getStructuringElement, MORPH_ELLIPSE

a = getStructuringElement(MORPH_ELLIPSE, (3, 3))

With opencv-python-4.5.3.56:

$ pylint test.py --extension-pkg-whitelist=cv2

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

With opencv-python-4.5.4.58:

$ pylint test.py --extension-pkg-whitelist=cv2
************* Module test
test.py:2:0: E0611: No name 'getStructuringElement' in module 'cv2' (no-name-in-module)
test.py:2:0: E0611: No name 'MORPH_ELLIPSE' in module 'cv2' (no-name-in-module)

----------------------------------------------------------------------
Your code has been rated at -40.00/10 (previous run: 10.00/10, -50.00)
Issue submission checklist
  • This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
  • I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
  • The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")
  • I'm using the latest version of opencv-python

Activity

  1. alalek commented on Oct 21, 2021

    @alalek
    Member

    BTW, does it work with --unsafe-load-any-extension=y: https://pylint.pycqa.org/en/latest/technical_reference/c_extensions.html

  2. robertschweizer commented on Oct 21, 2021

    @robertschweizer
    Author

    Good idea, maybe the C extension name just changed. But no, with --unsafe-load-any-extension=y it also does not work.

  3. jaime-dangelmeier commented on Oct 26, 2021

    @jaime-dangelmeier

    I also tried using the generated-members = cv2.* flag for pylint => still the same issue.

  4. self-assigned this
    on Nov 3, 2021
  5. asmorkalov commented on Nov 22, 2021

    @asmorkalov
    Collaborator

    Since 4.5.4.60 pylint works with OpenCV python loader correctly. Command line example:

    python3 -m pylint --extension-pkg-whitelist=cv2,numpy ./contours.py
    
  6. robertschweizer commented on Jun 10, 2022

    @robertschweizer
    Author

    The fix for this was reverted in 5633cf3, so this bug appears again in version 4.6.0.66. Should we rename and reopen this issue or create a new one?

  7. pasbi commented on Aug 10, 2022

    @pasbi

    I get the Module 'cv2' has no '*' member-pylint-error with

    • ❌ python3-opencv (4.6.0 installed with apt)
    • ❌ opencv-python (4.6.0 installed with pip)
    • ❌ self-built OpenCV (using GitHub repos opencv/opencv and opencv/opencv_contrib but not using opencv-python).
    • ✔️ The only way I found to make pylint work was to install version 4.5.5 of opencv-python with pip.

    However, I'm required to build OpenCV from source for technical reasons.
    What's the charm that lets the 4.5.5 pip wheel work with pylint and how can I apply it to my self-built OpenCV?

    Build and test environment is a debian bookworm Docker container.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions