ramonhagenaars / nptyping

💡 Type hints for Numpy and Pandas
MIT License
576 stars 29 forks source link

Mypy fails when `isinstance` is used with nptyping type #121

Open nazikus opened 2 months ago

nazikus commented 2 months ago

Basic example test.py:

import cv2
from nptyping import Float64, NDArray, Shape
Image = NDArray[Shape["H, W, 3"], Float64]
image = cv2.imread("image.png")
assert isinstance(image, Image)

Run:

> pip install -U opencv-python==4.10.0.84 nptyping==2.5.0 mypy==1.10.1
> mypy test.py
test.py:5: error: Parameterized generics cannot be used with class or instance checks  [misc]

How to use nptyping with opencv and isinstance() properly so mypy check is passed?