diff --git a/src/numpy-stubs/lib/_arrayterator_impl.pyi b/src/numpy-stubs/lib/_arrayterator_impl.pyi index ca8906c9..ce4528c1 100644 --- a/src/numpy-stubs/lib/_arrayterator_impl.pyi +++ b/src/numpy-stubs/lib/_arrayterator_impl.pyi @@ -1,15 +1,19 @@ -from collections.abc import Generator, Iterator +# pyright: reportIncompatibleMethodOverride=false + +from collections.abc import Generator from types import EllipsisType -from typing import Any, Generic, TypeAlias +from typing import Any, Final, Generic, TypeAlias from typing_extensions import TypeVar import numpy as np __all__ = ["Arrayterator"] +### + _ShapeT_co = TypeVar("_ShapeT_co", bound=tuple[int, ...], default=tuple[int, ...], covariant=True) _DTypeT_co = TypeVar("_DTypeT_co", bound=np.dtype[Any], default=np.dtype[Any], covariant=True) -_SCT = TypeVar("_SCT", bound=np.generic) +_ScalarT = TypeVar("_ScalarT", bound=np.generic) _AnyIndex: TypeAlias = EllipsisType | int | slice | tuple[EllipsisType | int | slice, ...] @@ -19,18 +23,17 @@ _AnyIndex: TypeAlias = EllipsisType | int | slice | tuple[EllipsisType | int | s # former and thus has access to all its methods class Arrayterator(np.ndarray[_ShapeT_co, _DTypeT_co], Generic[_ShapeT_co, _DTypeT_co]): var: np.ndarray[_ShapeT_co, _DTypeT_co] # type: ignore[assignment] - buf_size: int | None - start: list[int] - stop: list[int] - step: list[int] + buf_size: Final[int | None] + start: Final[list[int]] + stop: Final[list[int]] + step: Final[list[int]] - @property + @property # type: ignore[misc] def shape(self) -> _ShapeT_co: ... @property - def flat(self: Arrayterator[Any, np.dtype[_SCT]]) -> Generator[_SCT]: ... + def flat(self: Arrayterator[Any, np.dtype[_ScalarT]]) -> Generator[_ScalarT]: ... # type: ignore[override] # - def __init__(self, var: np.ndarray[_ShapeT_co, _DTypeT_co], buf_size: int | None = ...) -> None: ... - def __array__(self, dtype: None = ..., copy: bool | None = ...) -> np.ndarray[_ShapeT_co, _DTypeT_co]: ... - def __getitem__(self, index: _AnyIndex, /) -> Arrayterator[tuple[int, ...], _DTypeT_co]: ... - def __iter__(self) -> Iterator[np.ndarray[tuple[int, ...], _DTypeT_co]]: ... + def __init__(self, /, var: np.ndarray[_ShapeT_co, _DTypeT_co], buf_size: int | None = None) -> None: ... + def __getitem__(self, index: _AnyIndex, /) -> Arrayterator[tuple[int, ...], _DTypeT_co]: ... # type: ignore[override] + def __iter__(self) -> Generator[np.ndarray[tuple[int, ...], _DTypeT_co]]: ...