-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
TYP: allow None
in operand sequence of nditer
#28039
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
Conversation
Prevent type-hint errors when using `nditer` in an intended way (see https://numpy.org/doc/stable/reference/arrays.nditer.html#iterator-allocated-output-arrays). Fix #28038
I have the following concern regarding the way I have changed the type annotation: I leave it up to the maintainers to decide if it is more important to not raise a type-checking error on intended usage or to raise an error when passing a Sequence[None]-type value as |
I'm afraid that's inevitable, as there's no way to express "a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to prevent the new None
from accidentally being deleted in the future, it could help to add a quick type-test for this (in numpy/typing/tests/data
, in either reveal
or pass
)
I added such a type test in cf3dc6b based on the information I found in the testing readme of the archived numpy-stubs repository as I could not find any information in the numpy repository itself. If this information is still up to date, maybe it should be migrated to this repository as well? |
Yea that's a good point. There's a good chance we'll be overhauling the type-tests soon, so I suppose we'll take that into consideration once we do that :) |
Thanks, Simon! |
None
in operand sequence of nditerNone
in operand sequence of nditer
Prevent type-hint errors when using
nditer
in an intended way (see https://numpy.org/doc/stable/reference/arrays.nditer.html#iterator-allocated-output-arrays).Fix #28038