Skip to content

Commit 6ffa543

Browse files
MAINT: add missing dunder methods to nditer type hints
The presence of __getattr__ is not sufficient to enable all protocols so explicitely add the dunder methods supported by nditer
1 parent c3d1107 commit 6ffa543

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

numpy/__init__.pyi

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ from typing import (
172172
Generic,
173173
IO,
174174
Iterable,
175+
Iterator,
175176
List,
176177
Mapping,
177178
NoReturn,
@@ -778,6 +779,21 @@ class nditer:
778779
buffersize: Any = ...,
779780
) -> Any: ...
780781
def __getattr__(self, key: str) -> Any: ...
782+
def __enter__(self) -> nditer: ...
783+
def __exit__(
784+
self,
785+
exc_type: None | Type[BaseException],
786+
exc_value: None | BaseException,
787+
traceback: None | TracebackType,
788+
) -> None: ...
789+
def __iter__(self) -> Iterator[Any]: ...
790+
def __next__(self) -> Any: ...
791+
def __len__(self) -> int: ...
792+
def __copy__(self) -> nditer: ...
793+
def __getitem__(self, index: SupportsIndex | slice) -> Any: ...
794+
def __setitem__(self, index: SupportsIndex | slice, value: Any) -> None: ...
795+
def __delitem__(self, key: SupportsIndex | slice) -> None: ...
796+
781797

782798
class poly1d:
783799
def __init__(

0 commit comments

Comments
 (0)