Skip to content

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

Merged
charris merged 1 commit into
numpy:mainfrom
jorenham:typing/ndarray-missing-annotations
Nov 14, 2024
Merged

charris merged 1 commit into
numpy:mainfrom
jorenham:typing/ndarray-missing-annotations

Conversation

@jorenham

Copy link
Copy Markdown
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
@charris

charris commented Nov 14, 2024

Copy link
Copy Markdown
Member

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