Skip to content

Python type stubs: __all__ and __version__ dunders are missing #23950

@Avasam

Description

@Avasam

System Information

OpenCV python: opencv-python-headless==4.8.0.74
Operating System / Platform: 10.0.19045 Build 19045
Python version: 3.9.13

Detailed description

cv2.__all__ and cv2.__version__ are missing from the stubs.

cv2.__version__ is useful for compatibility checks.
cv2.__all__ is important for type checkers to know which symbols are.

Without __all__ specified:
image

With __all__ = [] specified:
image

Runtime:

>>> from cv2 import *
>>> SORT_EVERY_ROW
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'SORT_EVERY_ROW' is not defined

Steps to reproduce

>>> import cv2
>>> [x for x in dir(cv2) if x.startswith("__") and x.endswith("__")]
['__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__']
import cv2
cv2.__all__  # "__all__" is not a known member of module "cv2"
cv2.__builtins__
cv2.__cached__
cv2.__doc__
cv2.__file__
cv2.__loader__
cv2.__name__
cv2.__package__
cv2.__path__
cv2.__spec__
cv2.__version__  # "__version__" is not a known member of module "cv2"

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions