Open MilanStaffehl opened 3 weeks ago
Regarding the built-in types: https://github.com/numpy/numpy/issues/23663
np.float_
is a subtype of float
, so there is a relation, it's just "upside-down" with numpy
generics being subtypes of the built-in, not the other way around.
Seeing as how #6 was seemingly a sleep-deprived mistake on my end, this issue is now mostly related to using built-in types in NDArray
types. Will update title accordingly, and will later update the description as well.
See comment in #6.
Bug fix for #6:
Sometimes, type checkers will complain about certain dypes, since they are not actually typed as subtypes of np.generic in numpy. Example:
The above example, run against mypy on a 64-bit architecture, results in the following error:
A very similar issue occurs when using builtins, which are technically allowed as ndarray dtypes, but will also cause an error:
The error is similar:
Potentially one could get around the problem by writing a custom type that includes
type[floating[Any]]
etc. plus built-ins and then just ignore the fact thatnp.ndarray
is typed in a way that will not allow this type (since it only acceptsnp.generic
as dtype - which these apparently aren't).