You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By clicking &l
8000
dquo;Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
FWIW, with mypy I got Any for this instead of NoReturn.
But with np 1.22.0rc2, I get 'numpy.ndarray[Any, numpy.dtype[numpy.floating[Any]]]', which is almost fully accurate (except for not having the 64Bit part).
The root of this issue lies in how overload ambiguity is handled (xref microsoft/pyright#2521). The difference between mypy and pyright is that the former will return Any in such a situation (as was noted in @a-reich's comment), while the latter will pick the first overload, i.e. the np.bool_-based one that returns NoReturn.
With the way pyright handles overload ambiguity it effectively means that the arrays dtype must be known, lest you'll end up with inro. This can be accomplished either via explicitly specifying the dtype yourself or via improving the dtype-typing support in numpy itself.
The good news is that the numpy 1.22 should help quite a bit here, and the specific example that you showed is now successfully inferred as returning an array with a np.floating-based dtype. The bad news is that dtype-typing is, quite frankly, non trivial and I expect that a significant number of gaps will remain for the foreseeable future (xref #19252), gaps that will be filled in with Any.
Describe the issue:
Subtracting two np.ndarrays is infered to "return"
NoReturn
.See microsoft/pyright#2696 (comment) for @erictraut's analysis into why pyright infers
NoReturn
.Reproduce the code example:
Error message:
NumPy/Python version information:
1.21.4, 3.9.6
The text was updated successfully, but these errors were encountered: