Closed
Description
Describe the issue:
mypy
reports an error in the following code. Comparing ndarray[Any, dtype[signedinteger[_64Bit]]]
and ndarray[Any, dtype[signedinteger[NBitBase]]]
, the only difference seems to be _64Bit
vs. NBitBase
- although the former is a subclass of the latter:
numpy/numpy/_typing/__init__.py
Lines 67 to 80 in a277f62
Reproduce the code example:
import numpy as np
import numpy.typing as npt
def fun(array: npt.NDArray[np.bool_]) -> npt.NDArray[np.signedinteger[npt.NBitBase]]:
return np.flatnonzero(array)
Error message:
C:\Code\project>mypy bug.py
bug.py:5: error: Incompatible return value type (got "ndarray[Any, dtype[signedinteger[_64Bit]]]", expected "ndarray[Any, dtype[signedinteger[NBitBase]]]") [return-value]
Found 1 error in 1 file (checked 1 source file)
Runtime information:
1.25.2
3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)]
Context for the issue:
I had to choose between reporting this at mypy
or here first. Hope I made a decent choice, but I am happy to report elsewhere as well.