-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Overloaded return types with np.cross NoReturn leads to type-checking issues #22146
Comments
I have the same problem, and i just commented out the NoReturn function. |
I have also the same problem. Pylance marked some lines as unreachable. (The temporary remedy could be the usage of "dtype" in numpy.cross function) |
Yeah, I would prefer to not have to manually modify my own installation of NumPy to adjust this, and this should be a relatively quick fix for the development team |
I also have the same problem. I cannot solve it even if I specify the array type. |
Pyright just chooses the first matching type whenever there is ambiguity in type resolution, which leads to NoReturn for the cross function in certain situations. Other overloads were changed to match. See ticket numpy#22146
Pyright just chooses the first matching type whenever there is ambiguity in type resolution, which leads to NoReturn for the cross function in certain situations. Other overloads were changed to match. See ticket numpy#22146
Pyright just chooses the first matching type whenever there is ambiguity in type resolution, which leads to NoReturn for the cross function in certain situations. Other overloads were changed to match. See ticket numpy#22146
Reopen this issue? --> #22359 (comment) |
this issue returned. for a while now. |
@Liquidmasl please tell us a bit more: how are you seeing this? Is it exactly like in the original description? What version of NumPy are you using? |
EDIT: I just found this issue: #24999
i use 1.36.3 when checking the overloads there is this one overload: @overload
def cross(
a: _ArrayLikeBool_co,
b: _ArrayLikeBool_co,
axisa: int = ...,
axisb: int = ...,
axisc: int = ...,
axis: None | int = ...,
) -> NoReturn: ... which seams to be the issue. although i dont quite understand why the arrays are assumed to be dtype bool even declaring dtypes on the input arrays does not help But maybe this is a completely different issue? maybe i should comment there? #22359 (comment) (sorry i am somewhat new to the open source world.) EDIT: I just found this issue: #24999 |
Describe the issue:
np.cross appears to have a return type of
NoReturn
when dealing with_ArrayLikeBool_co
type, and thisNoReturn
type is incompatible with type checking in Pylance, and VSCode determines that all code after a call to np.cross is unreachable.This has been mentioned in a Pylance issue here (microsoft/pylance-release#3195), but they recommended mentioning it with NumPy.
Reproduce the code example:
Error message:
No response
NumPy/Python version information:
1.23.2 3.9.12 (main, Jun 12 2022, 13:39:05)
[GCC 9.4.0]
Context for the issue:
My code uses np.cross in many places, as well as extensive type-checking. It would be very nice if the return types could be cleaned up to improve compatibility with VSCode/Pylance/Pyright, because right now all of my code is grayed-out
The text was updated successfully, but these errors were encountered: