Skip to content

Alias typing (stdlib) in cv2/__init__.pyi and explicitely re-export cv2.typing #24352

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
4 tasks done
Avasam opened this issue Oct 3, 2023 · 0 comments · Fixed by #24356
Closed
4 tasks done

Alias typing (stdlib) in cv2/__init__.pyi and explicitely re-export cv2.typing #24352

Avasam opened this issue Oct 3, 2023 · 0 comments · Fixed by #24356

Comments

@Avasam
Copy link
Contributor

Avasam commented Oct 3, 2023

System Information

OpenCV python version: 4.8.1.78
Operating System / Platform: Windows 10
Python version: 3.9.13

Detailed description

Aliasing typing (stdlib) in cv2/__init__.pyi works around python/mypy#16216 and fixes opencv/opencv-python#901
And allow type checkers to see that the typing symbol in cv2 at runtime is actually cv2.typing.

It would look something like that:

import typing as _typing
from cv2 import typing as typing

Steps to reproduce

See opencv/opencv-python#901

import cv2
import cv2.typing

_ = cv2.typing.MatLike

and:

import cv2

_ = cv2.typing.MatLike

test with both pyright and mypy

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)
@Avasam Avasam added the bug label Oct 3, 2023
@Avasam Avasam changed the title Alias typing (stdlib) in cv2/__init__.pyi Alias typing (stdlib) in cv2/__init__.pyi and explicitely re-export cv2.typing Oct 3, 2023
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.

3 participants