You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Type stub cv2 imports typing
Module cv2.typing also exists
The following raises a mypy error, as expected
importcv2_=cv2.typing.MatLike# Module "cv2" does not explicitly export attribute "typing" Mypy [attr-defined]
(note that this will work at runtime, by that's because cv2 doesn't actually import typing at runtime AND does dynamic imports to expose all its submodules, so mypy is correct here in terms of static type-checking)
The following works, and is accepted by mypy, as expected
importcv2.typing_=cv2.typing.MatLike
The issue comes from importing both:
importcv2importcv2.typing
Note that pyright handles this case correctly.
(A clear and concise description of what the bug is.)
To Reproduce
Download the reproduction, then run mypy . at the root. See error
Run python test.py, see the symbol printed out. Minimal repro.zip
Expected Behavior
No error in repro
Actual Behavior
PS C:\Users\Avasam\Desktop\Minimal repro> mypy .
test.py:4: error: Module has no attribute "Foo" [attr-defined]
Found 1 error in 1 file (checked 3 source files)
Your Environment
Mypy version used: mypy 1.5.1 (compiled: yes)
Mypy command-line flags: None
Mypy configuration options from mypy.ini (and other config files): None
Python version used: Python 3.9.13
The text was updated successfully, but these errors were encountered:
Bug Report
This is happening in opencv, relevant issue: opencv/opencv-python#901
Type stub
cv2
importstyping
Module
cv2.typing
also existsThe following raises a mypy error, as expected
(note that this will work at runtime, by that's because
cv2
doesn't actually importtyping
at runtime AND does dynamic imports to expose all its submodules, so mypy is correct here in terms of static type-checking)The following works, and is accepted by mypy, as expected
The issue comes from importing both:
Note that pyright handles this case correctly.
(A clear and concise description of what the bug is.)
To Reproduce
Download the reproduction, then run
mypy .
at the root. See errorRun
python test.py
, see the symbol printed out.Minimal repro.zip
Expected Behavior
No error in repro
Actual Behavior
Your Environment
mypy.ini
(and other config files): NoneThe text was updated successfully, but these errors were encountered: