Skip to content

Commit 08410d5

Browse files
committed
🏷️ fix stubtest errors in lib._arrayterator_impl
1 parent 3ccd3f7 commit 08410d5

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.mypyignore-todo

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ numpy._pyinstaller.hook-numpy
1515
numpy.ctypeslib._ctypeslib
1616
numpy.fft.helper
1717

18-
numpy.lib(._arrayterator_impl)?.Arrayterator.__array__
1918
numpy.lib.(_array_utils_impl|array_utils).normalize_axis_tuple
2019
numpy.lib._iotools.NameValidator.defaultdeletechars
2120
numpy.lib.format.open_memmap

src/numpy-stubs/lib/_arrayterator_impl.pyi

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from collections.abc import Generator
44
from types import EllipsisType
5-
from typing import Any, Final, Generic, TypeAlias
5+
from typing import Any, Final, Generic, TypeAlias, overload
66
from typing_extensions import TypeVar
77

88
import numpy as np
@@ -12,6 +12,7 @@ __all__ = ["Arrayterator"]
1212
###
1313

1414
_ShapeT_co = TypeVar("_ShapeT_co", bound=tuple[int, ...], default=tuple[int, ...], covariant=True)
15+
_DTypeT = TypeVar("_DTypeT", bound=np.dtype[Any])
1516
_DTypeT_co = TypeVar("_DTypeT_co", bound=np.dtype[Any], default=np.dtype[Any], covariant=True)
1617
_ScalarT = TypeVar("_ScalarT", bound=np.generic)
1718

@@ -37,3 +38,9 @@ class Arrayterator(np.ndarray[_ShapeT_co, _DTypeT_co], Generic[_ShapeT_co, _DTyp
3738
def __init__(self, /, var: np.ndarray[_ShapeT_co, _DTypeT_co], buf_size: int | None = None) -> None: ... # pyright: ignore[reportInconsistentConstructor]
3839
def __getitem__(self, index: _AnyIndex, /) -> Arrayterator[tuple[int, ...], _DTypeT_co]: ... # type: ignore[override]
3940
def __iter__(self) -> Generator[np.ndarray[tuple[int, ...], _DTypeT_co]]: ...
41+
42+
#
43+
@overload # type: ignore[override]
44+
def __array__(self, /, dtype: _DTypeT_co | None = None, copy: bool | None = None) -> np.ndarray[_ShapeT_co, _DTypeT_co]: ...
45+
@overload
46+
def __array__(self, /, dtype: _DTypeT, copy: bool | None = None) -> np.ndarray[_ShapeT_co, _DTypeT]: ...

0 commit comments

Comments
 (0)