Skip to content

TYP: Annotate __setitem__, __contains__ and __iter__ of ndarray #27755

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

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

jorenham
Copy link
Member

The __setitem__ and __contains__ methods of ndarray were actually missing, which was causing errors in 3rd party libraries that ran pyright --verifytypes.

For __iter__ the return type was annotated as Any. It will now returns an iterator of scalars or arrays, depending on its shape (1-d vs. >1-d).

The changes in __getitem__ are the result of a newly extracted type alias for the index type, as to avoid duplication with the added annotations for __setitem__.

@charris charris merged commit 44c2263 into numpy:main Nov 14, 2024
70 checks passed
@charris
Copy link
Member

charris commented Nov 14, 2024

Thanks Joren.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants