Skip to content

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

@Avasam

Description

@Avasam

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)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions