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
{{ message }}
Repository navigation
BUG: typings: a - b returns NoReturn instead of ndarray #20265
Interestingly, it appears that this bug is not limited to mypy (xref python/mypy#11347).
Annoying as it is, I'm wondering if it might be best to temporarily remove the dunder overloads...
It's funny that only - is concerned, not +, *, or /.
The problem is that self annotations are ignored when a Any-parametrized object is passed to an overload method.
So what happens is that np.ndarray (or equivalently np.ndarray[Any, Any]) will just pick whatever happens to be the first overload, which turns out to be to NoReturn overload used for boolean arrays:
Activity
BvB93 commentedon Nov 1, 2021
Duplicate of #20099 and (to some extent) #20072.
Interestingly, it appears that this bug is not limited to mypy (xref python/mypy#11347).
Annoying as it is, I'm wondering if it might be best to temporarily remove the dunder overloads...
nschloe commentedon Nov 1, 2021
It's funny that only
-is concerned, not+,*, or/.BvB93 commentedon Nov 1, 2021
The problem is that
selfannotations are ignored when aAny-parametrized object is passed to an overload method.So what happens is that
np.ndarray(or equivalentlynp.ndarray[Any, Any]) will just pick whatever happens to be the first overload, which turns out to be toNoReturnoverload used for boolean arrays:numpy/numpy/__init__.pyi
Lines 2013 to 2014 in fa397e9
BvB93 commentedon Nov 1, 2021
Closing this in favor of #20099