diff options
| author | Sebastian Berg <sebastianb@nvidia.com> | 2023-02-21 16:19:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-21 16:19:59 +0100 |
| commit | 14e91c7475e5a18d86714c4dd7586ca4be995dfe (patch) | |
| tree | d79573141b3507f7cdf489865b1e29ff9a41bac4 /numpy | |
| parent | 7664dc02156e6804ef5d4f7277d2abdc6ac3477e (diff) | |
| parent | 8816c76631af79c46a8cf33ac1a8a79b2717c9ac (diff) | |
| download | numpy-14e91c7475e5a18d86714c4dd7586ca4be995dfe.tar.gz | |
Merge pull request #23256 from FrancescElies/cesc-set-generic-parameters-to-any
TYP,MAINT: Add a missing explicit Any parameter
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/__init__.pyi | 60 | ||||
| -rw-r--r-- | numpy/array_api/_array_object.py | 2 | ||||
| -rw-r--r-- | numpy/core/_asarray.pyi | 8 | ||||
| -rw-r--r-- | numpy/core/_type_aliases.pyi | 10 | ||||
| -rw-r--r-- | numpy/ctypeslib.pyi | 4 | ||||
| -rw-r--r-- | numpy/lib/index_tricks.pyi | 2 |
6 files changed, 43 insertions, 43 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index fb041ddc4..f144895be 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -678,7 +678,7 @@ alltrue = all def show_config() -> None: ... -_NdArraySubClass = TypeVar("_NdArraySubClass", bound=ndarray) +_NdArraySubClass = TypeVar("_NdArraySubClass", bound=ndarray[Any, Any]) _DTypeScalar_co = TypeVar("_DTypeScalar_co", covariant=True, bound=generic) _ByteOrder = L["S", "<", ">", "=", "|", "L", "B", "N", "I"] @@ -804,7 +804,7 @@ class dtype(Generic[_DTypeScalar_co]): @overload def __new__(cls, dtype: _VoidCodes, align: bool = ..., copy: bool = ...) -> dtype[void]: ... @overload - def __new__(cls, dtype: _ObjectCodes | type[ct.py_object], align: bool = ..., copy: bool = ...) -> dtype[object_]: ... + def __new__(cls, dtype: _ObjectCodes | type[ct.py_object[Any]], align: bool = ..., copy: bool = ...) -> dtype[object_]: ... # dtype of a dtype is the same dtype @overload @@ -928,13 +928,13 @@ class dtype(Generic[_DTypeScalar_co]): _ArrayLikeInt = Union[ int, - integer, - Sequence[Union[int, integer]], + integer[Any], + Sequence[Union[int, integer[Any]]], Sequence[Sequence[Any]], # TODO: wait for support for recursive types - ndarray + ndarray[Any, Any] ] -_FlatIterSelf = TypeVar("_FlatIterSelf", bound=flatiter) +_FlatIterSelf = TypeVar("_FlatIterSelf", bound=flatiter[Any]) @final class flatiter(Generic[_NdArraySubClass]): @@ -952,7 +952,7 @@ class flatiter(Generic[_NdArraySubClass]): @overload def __getitem__( self: flatiter[ndarray[Any, dtype[_ScalarType]]], - key: int | integer | tuple[int | integer], + key: int | integer[Any] | tuple[int | integer[Any]], ) -> _ScalarType: ... @overload def __getitem__( @@ -1147,7 +1147,7 @@ class _ArrayOrScalarCommon: axis: None | SupportsIndex = ..., kind: None | _SortKind = ..., order: None | str | Sequence[str] = ..., - ) -> ndarray: ... + ) -> ndarray[Any, Any]: ... @overload def choose( @@ -1155,7 +1155,7 @@ class _ArrayOrScalarCommon: choices: ArrayLike, out: None = ..., mode: _ModeKind = ..., - ) -> ndarray: ... + ) -> ndarray[Any, Any]: ... @overload def choose( self, @@ -1171,7 +1171,7 @@ class _ArrayOrScalarCommon: max: None | ArrayLike = ..., out: None = ..., **kwargs: Any, - ) -> ndarray: ... + ) -> ndarray[Any, Any]: ... @overload def clip( self, @@ -1179,7 +1179,7 @@ class _ArrayOrScalarCommon: max: ArrayLike = ..., out: None = ..., **kwargs: Any, - ) -> ndarray: ... + ) -> ndarray[Any, Any]: ... @overload def clip( self, @@ -1203,7 +1203,7 @@ class _ArrayOrScalarCommon: a: ArrayLike, axis: None | SupportsIndex = ..., out: None = ..., - ) -> ndarray: ... + ) -> ndarray[Any, Any]: ... @overload def compress( self, @@ -1222,7 +1222,7 @@ class _ArrayOrScalarCommon: axis: None | SupportsIndex = ..., dtype: DTypeLike = ..., out: None = ..., - ) -> ndarray: ... + ) -> ndarray[Any, Any]: ... @overload def cumprod( self, @@ -1237,7 +1237,7 @@ class _ArrayOrScalarCommon: axis: None | SupportsIndex = ..., dtype: DTypeLike = ..., out: None = ..., - ) -> ndarray: ... + ) -> ndarray[Any, Any]: ... @overload def cumsum( self, @@ -1482,7 +1482,7 @@ class _SupportsImag(Protocol[_T_co]): class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]): __hash__: ClassVar[None] @property - def base(self) -> None | ndarray: ... + def base(self) -> None | ndarray[Any, Any]: ... @property def ndim(self) -> int: ... @property @@ -1649,7 +1649,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]): # 1D + 1D returns a scalar; # all other with at least 1 non-0D array return an ndarray. @overload - def dot(self, b: _ScalarLike_co, out: None = ...) -> ndarray: ... + def dot(self, b: _ScalarLike_co, out: None = ...) -> ndarray[Any, Any]: ... @overload def dot(self, b: ArrayLike, out: None = ...) -> Any: ... # type: ignore[misc] @overload @@ -2826,20 +2826,20 @@ class integer(number[_NBit1]): # type: ignore def __index__(self) -> int: ... __truediv__: _IntTrueDiv[_NBit1] __rtruediv__: _IntTrueDiv[_NBit1] - def __mod__(self, value: _IntLike_co) -> integer: ... - def __rmod__(self, value: _IntLike_co) -> integer: ... + def __mod__(self, value: _IntLike_co) -> integer[Any]: ... + def __rmod__(self, value: _IntLike_co) -> integer[Any]: ... def __invert__(self: _IntType) -> _IntType: ... # Ensure that objects annotated as `integer` support bit-wise operations - def __lshift__(self, other: _IntLike_co) -> integer: ... - def __rlshift__(self, other: _IntLike_co) -> integer: ... - def __rshift__(self, other: _IntLike_co) -> integer: ... - def __rrshift__(self, other: _IntLike_co) -> integer: ... - def __and__(self, other: _IntLike_co) -> integer: ... - def __rand__(self, other: _IntLike_co) -> integer: ... - def __or__(self, other: _IntLike_co) -> integer: ... - def __ror__(self, other: _IntLike_co) -> integer: ... - def __xor__(self, other: _IntLike_co) -> integer: ... - def __rxor__(self, other: _IntLike_co) -> integer: ... + def __lshift__(self, other: _IntLike_co) -> integer[Any]: ... + def __rlshift__(self, other: _IntLike_co) -> integer[Any]: ... + def __rshift__(self, other: _IntLike_co) -> integer[Any]: ... + def __rrshift__(self, other: _IntLike_co) -> integer[Any]: ... + def __and__(self, other: _IntLike_co) -> integer[Any]: ... + def __rand__(self, other: _IntLike_co) -> integer[Any]: ... + def __or__(self, other: _IntLike_co) -> integer[Any]: ... + def __ror__(self, other: _IntLike_co) -> integer[Any]: ... + def __xor__(self, other: _IntLike_co) -> integer[Any]: ... + def __rxor__(self, other: _IntLike_co) -> integer[Any]: ... class signedinteger(integer[_NBit1]): def __init__(self, value: _IntValue = ..., /) -> None: ... @@ -2964,8 +2964,8 @@ ulonglong = unsignedinteger[_NBitLongLong] class inexact(number[_NBit1]): # type: ignore def __getnewargs__(self: inexact[_64Bit]) -> tuple[float, ...]: ... -_IntType = TypeVar("_IntType", bound=integer) -_FloatType = TypeVar('_FloatType', bound=floating) +_IntType = TypeVar("_IntType", bound=integer[Any]) +_FloatType = TypeVar('_FloatType', bound=floating[Any]) class floating(inexact[_NBit1]): def __init__(self, value: _FloatValue = ..., /) -> None: ... diff --git a/numpy/array_api/_array_object.py b/numpy/array_api/_array_object.py index c4746fad9..eee117be6 100644 --- a/numpy/array_api/_array_object.py +++ b/numpy/array_api/_array_object.py @@ -56,7 +56,7 @@ class Array: functions, such as asarray(). """ - _array: np.ndarray + _array: np.ndarray[Any, Any] # Use a custom constructor instead of __init__, as manually initializing # this class is not supported API. diff --git a/numpy/core/_asarray.pyi b/numpy/core/_asarray.pyi index 473bc037c..69d1528d4 100644 --- a/numpy/core/_asarray.pyi +++ b/numpy/core/_asarray.pyi @@ -1,10 +1,10 @@ from collections.abc import Iterable -from typing import TypeVar, Union, overload, Literal +from typing import Any, TypeVar, Union, overload, Literal from numpy import ndarray from numpy._typing import DTypeLike, _SupportsArrayFunc -_ArrayType = TypeVar("_ArrayType", bound=ndarray) +_ArrayType = TypeVar("_ArrayType", bound=ndarray[Any, Any]) _Requirements = Literal[ "C", "C_CONTIGUOUS", "CONTIGUOUS", @@ -31,7 +31,7 @@ def require( requirements: _E | Iterable[_RequirementsWithE] = ..., *, like: _SupportsArrayFunc = ... -) -> ndarray: ... +) -> ndarray[Any, Any]: ... @overload def require( a: object, @@ -39,4 +39,4 @@ def require( requirements: None | _Requirements | Iterable[_Requirements] = ..., *, like: _SupportsArrayFunc = ... -) -> ndarray: ... +) -> ndarray[Any, Any]: ... diff --git a/numpy/core/_type_aliases.pyi b/numpy/core/_type_aliases.pyi index bbead0cb5..c0b6f1a80 100644 --- a/numpy/core/_type_aliases.pyi +++ b/numpy/core/_type_aliases.pyi @@ -1,12 +1,12 @@ -from typing import TypedDict +from typing import Any, TypedDict from numpy import generic, signedinteger, unsignedinteger, floating, complexfloating class _SCTypes(TypedDict): - int: list[type[signedinteger]] - uint: list[type[unsignedinteger]] - float: list[type[floating]] - complex: list[type[complexfloating]] + int: list[type[signedinteger[Any]]] + uint: list[type[unsignedinteger[Any]]] + float: list[type[floating[Any]]] + complex: list[type[complexfloating[Any, Any]]] others: list[type] sctypeDict: dict[int | str, type[generic]] diff --git a/numpy/ctypeslib.pyi b/numpy/ctypeslib.pyi index 0313cd82a..3edf98e14 100644 --- a/numpy/ctypeslib.pyi +++ b/numpy/ctypeslib.pyi @@ -91,10 +91,10 @@ class _ndptr(ctypes.c_void_p, Generic[_DTypeOptional]): @overload @classmethod - def from_param(cls: type[_ndptr[None]], obj: ndarray[Any, Any]) -> _ctypes: ... + def from_param(cls: type[_ndptr[None]], obj: ndarray[Any, Any]) -> _ctypes[Any]: ... @overload @classmethod - def from_param(cls: type[_ndptr[_DType]], obj: ndarray[Any, _DType]) -> _ctypes: ... + def from_param(cls: type[_ndptr[_DType]], obj: ndarray[Any, _DType]) -> _ctypes[Any]: ... class _concrete_ndptr(_ndptr[_DType]): _dtype_: ClassVar[_DType] diff --git a/numpy/lib/index_tricks.pyi b/numpy/lib/index_tricks.pyi index c9251abd1..29a6b9e2b 100644 --- a/numpy/lib/index_tricks.pyi +++ b/numpy/lib/index_tricks.pyi @@ -119,7 +119,7 @@ class AxisConcatenator: @staticmethod def makemat( data: ArrayLike, dtype: DTypeLike = ..., copy: bool = ... - ) -> _Matrix: ... + ) -> _Matrix[Any, Any]: ... # TODO: Sort out this `__getitem__` method def __getitem__(self, key: Any) -> Any: ... |
