I'm trying to type hint a numpy ndarray like this:
RGB = numpy.dtype[numpy.uint8]
ThreeD = tuple[int, int, int]
def load_images(paths: list[str]) -> tuple[list[numpy.ndarray[ThreeD, RGB]], list[str]]: ...
but at the first line when I run this, I got the following error:
RGB = numpy.dtype[numpy.uint8]
TypeError: 'numpy._DTypeMeta' object is not subscriptable
How do I type hint a ndarray correctly?
I had a similar issue with my opencv2 library, which I by upgrading numpy
pip install numpy --upgrade
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With