summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/__init__.pyi235
-rw-r--r--numpy/_pytesttester.pyi4
-rw-r--r--numpy/core/_internal.pyi8
-rw-r--r--numpy/core/_type_aliases.pyi14
-rw-r--r--numpy/core/arrayprint.pyi2
-rw-r--r--numpy/core/defchararray.pyi3
-rw-r--r--numpy/core/einsumfunc.pyi6
-rw-r--r--numpy/core/fromnumeric.pyi4
-rw-r--r--numpy/core/function_base.pyi17
-rw-r--r--numpy/core/getlimits.pyi4
-rw-r--r--numpy/core/memmap.pyi4
-rw-r--r--numpy/core/multiarray.pyi27
-rw-r--r--numpy/core/numeric.pyi31
-rw-r--r--numpy/core/numerictypes.pyi100
-rw-r--r--numpy/core/records.pyi8
-rw-r--r--numpy/core/shape_base.pyi10
-rw-r--r--numpy/ctypeslib.pyi58
-rw-r--r--numpy/f2py/__init__.pyi20
-rw-r--r--numpy/fft/__init__.pyi6
-rw-r--r--numpy/fft/_pocketfft.pyi3
-rw-r--r--numpy/fft/helper.pyi4
-rw-r--r--numpy/lib/__init__.pyi6
-rw-r--r--numpy/lib/_version.pyi4
-rw-r--r--numpy/lib/arraypad.pyi9
-rw-r--r--numpy/lib/arraysetops.pyi36
-rw-r--r--numpy/lib/arrayterator.pyi15
-rw-r--r--numpy/lib/format.pyi6
-rw-r--r--numpy/lib/function_base.pyi15
-rw-r--r--numpy/lib/histograms.pyi14
-rw-r--r--numpy/lib/index_tricks.pyi28
-rw-r--r--numpy/lib/mixins.pyi3
-rw-r--r--numpy/lib/nanfunctions.pyi4
-rw-r--r--numpy/lib/npyio.pyi12
-rw-r--r--numpy/lib/polynomial.pyi8
-rw-r--r--numpy/lib/scimath.pyi4
-rw-r--r--numpy/lib/shape_base.pyi28
-rw-r--r--numpy/lib/stride_tricks.pyi10
-rw-r--r--numpy/lib/twodim_base.pyi25
-rw-r--r--numpy/lib/type_check.pyi16
-rw-r--r--numpy/lib/ufunclike.pyi4
-rw-r--r--numpy/lib/utils.pyi6
-rw-r--r--numpy/linalg/__init__.pyi6
-rw-r--r--numpy/linalg/linalg.pyi26
-rw-r--r--numpy/ma/__init__.pyi6
-rw-r--r--numpy/ma/core.pyi4
-rw-r--r--numpy/ma/extras.pyi4
-rw-r--r--numpy/ma/mrecords.pyi6
-rw-r--r--numpy/matrixlib/__init__.pyi6
-rw-r--r--numpy/matrixlib/defmatrix.pyi4
-rw-r--r--numpy/polynomial/__init__.pyi6
-rw-r--r--numpy/polynomial/_polybase.pyi4
-rw-r--r--numpy/polynomial/chebyshev.pyi4
-rw-r--r--numpy/polynomial/hermite.pyi2
-rw-r--r--numpy/polynomial/hermite_e.pyi2
-rw-r--r--numpy/polynomial/laguerre.pyi2
-rw-r--r--numpy/polynomial/legendre.pyi2
-rw-r--r--numpy/polynomial/polynomial.pyi2
-rw-r--r--numpy/polynomial/polyutils.pyi4
-rw-r--r--numpy/random/__init__.pyi6
-rw-r--r--numpy/random/_generator.pyi34
-rw-r--r--numpy/random/bit_generator.pyi24
-rw-r--r--numpy/random/mtrand.pyi40
-rw-r--r--numpy/testing/__init__.pyi8
-rw-r--r--numpy/testing/_private/utils.pyi49
-rw-r--r--numpy/typing/_callable.pyi3
-rw-r--r--numpy/typing/_generic_alias.py26
-rw-r--r--numpy/typing/_ufunc.pyi44
-rw-r--r--numpy/typing/tests/data/fail/arithmetic.pyi16
-rw-r--r--numpy/typing/tests/data/fail/einsumfunc.pyi2
-rw-r--r--numpy/typing/tests/data/fail/index_tricks.pyi5
-rw-r--r--numpy/typing/tests/data/fail/multiarray.pyi3
-rw-r--r--numpy/typing/tests/data/fail/nested_sequence.pyi6
-rw-r--r--numpy/typing/tests/data/fail/random.pyi4
-rw-r--r--numpy/typing/tests/data/fail/twodim_base.pyi4
-rw-r--r--numpy/typing/tests/data/fail/ufunclike.pyi2
-rw-r--r--numpy/typing/tests/data/pass/literal.py6
-rw-r--r--numpy/typing/tests/data/pass/numeric.py5
-rw-r--r--numpy/typing/tests/data/pass/random.py39
-rw-r--r--numpy/typing/tests/data/reveal/arithmetic.pyi18
-rw-r--r--numpy/typing/tests/data/reveal/array_constructors.pyi4
-rw-r--r--numpy/typing/tests/data/reveal/arraypad.pyi7
-rw-r--r--numpy/typing/tests/data/reveal/einsumfunc.pyi14
-rw-r--r--numpy/typing/tests/data/reveal/index_tricks.pyi10
-rw-r--r--numpy/typing/tests/data/reveal/lib_utils.pyi4
-rw-r--r--numpy/typing/tests/data/reveal/multiarray.pyi6
-rw-r--r--numpy/typing/tests/data/reveal/nested_sequence.pyi6
-rw-r--r--numpy/typing/tests/data/reveal/npyio.pyi4
-rw-r--r--numpy/typing/tests/data/reveal/numeric.pyi3
-rw-r--r--numpy/typing/tests/data/reveal/random.pyi34
-rw-r--r--numpy/typing/tests/data/reveal/rec.pyi4
-rw-r--r--numpy/typing/tests/data/reveal/shape_base.pyi4
-rw-r--r--numpy/typing/tests/data/reveal/stride_tricks.pyi6
-rw-r--r--numpy/typing/tests/data/reveal/twodim_base.pyi4
-rw-r--r--numpy/typing/tests/data/reveal/type_check.pyi3
-rw-r--r--numpy/typing/tests/data/reveal/ufunclike.pyi12
-rw-r--r--numpy/typing/tests/data/reveal/warnings_and_errors.pyi2
-rw-r--r--numpy/typing/tests/test_generic_alias.py7
97 files changed, 648 insertions, 741 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi
index 039b9dfa7..c41bed873 100644
--- a/numpy/__init__.pyi
+++ b/numpy/__init__.pyi
@@ -174,12 +174,10 @@ from typing import (
Callable,
Container,
Callable,
- Dict,
Generic,
IO,
Iterable,
Iterator,
- List,
Mapping,
NoReturn,
overload,
@@ -189,8 +187,6 @@ from typing import (
SupportsFloat,
SupportsInt,
Text,
- Tuple,
- Type,
TypeVar,
Union,
Protocol,
@@ -198,7 +194,6 @@ from typing import (
Final,
final,
ClassVar,
- Set,
)
# Ensures that the stubs are picked up
@@ -654,8 +649,8 @@ class _MemMapIOProtocol(Protocol):
class _SupportsWrite(Protocol[_AnyStr_contra]):
def write(self, s: _AnyStr_contra, /) -> object: ...
-__all__: List[str]
-__path__: List[str]
+__all__: list[str]
+__path__: list[str]
__version__: str
__git_version__: str
test: PytestTester
@@ -682,12 +677,12 @@ _DTypeScalar_co = TypeVar("_DTypeScalar_co", covariant=True, bound=generic)
_ByteOrder = L["S", "<", ">", "=", "|", "L", "B", "N", "I"]
class dtype(Generic[_DTypeScalar_co]):
- names: None | Tuple[builtins.str, ...]
+ names: None | tuple[builtins.str, ...]
# Overload for subclass of generic
@overload
def __new__(
cls,
- dtype: Type[_DTypeScalar_co],
+ dtype: type[_DTypeScalar_co],
align: bool = ...,
copy: bool = ...,
) -> dtype[_DTypeScalar_co]: ...
@@ -701,64 +696,64 @@ class dtype(Generic[_DTypeScalar_co]):
# first.
# Builtin types
@overload
- def __new__(cls, dtype: Type[bool], align: bool = ..., copy: bool = ...) -> dtype[bool_]: ...
+ def __new__(cls, dtype: type[bool], align: bool = ..., copy: bool = ...) -> dtype[bool_]: ...
@overload
- def __new__(cls, dtype: Type[int], align: bool = ..., copy: bool = ...) -> dtype[int_]: ...
+ def __new__(cls, dtype: type[int], align: bool = ..., copy: bool = ...) -> dtype[int_]: ...
@overload
- def __new__(cls, dtype: None | Type[float], align: bool = ..., copy: bool = ...) -> dtype[float_]: ...
+ def __new__(cls, dtype: None | type[float], align: bool = ..., copy: bool = ...) -> dtype[float_]: ...
@overload
- def __new__(cls, dtype: Type[complex], align: bool = ..., copy: bool = ...) -> dtype[complex_]: ...
+ def __new__(cls, dtype: type[complex], align: bool = ..., copy: bool = ...) -> dtype[complex_]: ...
@overload
- def __new__(cls, dtype: Type[builtins.str], align: bool = ..., copy: bool = ...) -> dtype[str_]: ...
+ def __new__(cls, dtype: type[builtins.str], align: bool = ..., copy: bool = ...) -> dtype[str_]: ...
@overload
- def __new__(cls, dtype: Type[bytes], align: bool = ..., copy: bool = ...) -> dtype[bytes_]: ...
+ def __new__(cls, dtype: type[bytes], align: bool = ..., copy: bool = ...) -> dtype[bytes_]: ...
# `unsignedinteger` string-based representations and ctypes
@overload
- def __new__(cls, dtype: _UInt8Codes | Type[ct.c_uint8], align: bool = ..., copy: bool = ...) -> dtype[uint8]: ...
+ def __new__(cls, dtype: _UInt8Codes | type[ct.c_uint8], align: bool = ..., copy: bool = ...) -> dtype[uint8]: ...
@overload
- def __new__(cls, dtype: _UInt16Codes | Type[ct.c_uint16], align: bool = ..., copy: bool = ...) -> dtype[uint16]: ...
+ def __new__(cls, dtype: _UInt16Codes | type[ct.c_uint16], align: bool = ..., copy: bool = ...) -> dtype[uint16]: ...
@overload
- def __new__(cls, dtype: _UInt32Codes | Type[ct.c_uint32], align: bool = ..., copy: bool = ...) -> dtype[uint32]: ...
+ def __new__(cls, dtype: _UInt32Codes | type[ct.c_uint32], align: bool = ..., copy: bool = ...) -> dtype[uint32]: ...
@overload
- def __new__(cls, dtype: _UInt64Codes | Type[ct.c_uint64], align: bool = ..., copy: bool = ...) -> dtype[uint64]: ...
+ def __new__(cls, dtype: _UInt64Codes | type[ct.c_uint64], align: bool = ..., copy: bool = ...) -> dtype[uint64]: ...
@overload
- def __new__(cls, dtype: _UByteCodes | Type[ct.c_ubyte], align: bool = ..., copy: bool = ...) -> dtype[ubyte]: ...
+ def __new__(cls, dtype: _UByteCodes | type[ct.c_ubyte], align: bool = ..., copy: bool = ...) -> dtype[ubyte]: ...
@overload
- def __new__(cls, dtype: _UShortCodes | Type[ct.c_ushort], align: bool = ..., copy: bool = ...) -> dtype[ushort]: ...
+ def __new__(cls, dtype: _UShortCodes | type[ct.c_ushort], align: bool = ..., copy: bool = ...) -> dtype[ushort]: ...
@overload
- def __new__(cls, dtype: _UIntCCodes | Type[ct.c_uint], align: bool = ..., copy: bool = ...) -> dtype[uintc]: ...
+ def __new__(cls, dtype: _UIntCCodes | type[ct.c_uint], align: bool = ..., copy: bool = ...) -> dtype[uintc]: ...
# NOTE: We're assuming here that `uint_ptr_t == size_t`,
# an assumption that does not hold in rare cases (same for `ssize_t`)
@overload
- def __new__(cls, dtype: _UIntPCodes | Type[ct.c_void_p] | Type[ct.c_size_t], align: bool = ..., copy: bool = ...) -> dtype[uintp]: ...
+ def __new__(cls, dtype: _UIntPCodes | type[ct.c_void_p] | type[ct.c_size_t], align: bool = ..., copy: bool = ...) -> dtype[uintp]: ...
@overload
- def __new__(cls, dtype: _UIntCodes | Type[ct.c_ulong], align: bool = ..., copy: bool = ...) -> dtype[uint]: ...
+ def __new__(cls, dtype: _UIntCodes | type[ct.c_ulong], align: bool = ..., copy: bool = ...) -> dtype[uint]: ...
@overload
- def __new__(cls, dtype: _ULongLongCodes | Type[ct.c_ulonglong], align: bool = ..., copy: bool = ...) -> dtype[ulonglong]: ...
+ def __new__(cls, dtype: _ULongLongCodes | type[ct.c_ulonglong], align: bool = ..., copy: bool = ...) -> dtype[ulonglong]: ...
# `signedinteger` string-based representations and ctypes
@overload
- def __new__(cls, dtype: _Int8Codes | Type[ct.c_int8], align: bool = ..., copy: bool = ...) -> dtype[int8]: ...
+ def __new__(cls, dtype: _Int8Codes | type[ct.c_int8], align: bool = ..., copy: bool = ...) -> dtype[int8]: ...
@overload
- def __new__(cls, dtype: _Int16Codes | Type[ct.c_int16], align: bool = ..., copy: bool = ...) -> dtype[int16]: ...
+ def __new__(cls, dtype: _Int16Codes | type[ct.c_int16], align: bool = ..., copy: bool = ...) -> dtype[int16]: ...
@overload
- def __new__(cls, dtype: _Int32Codes | Type[ct.c_int32], align: bool = ..., copy: bool = ...) -> dtype[int32]: ...
+ def __new__(cls, dtype: _Int32Codes | type[ct.c_int32], align: bool = ..., copy: bool = ...) -> dtype[int32]: ...
@overload
- def __new__(cls, dtype: _Int64Codes | Type[ct.c_int64], align: bool = ..., copy: bool = ...) -> dtype[int64]: ...
+ def __new__(cls, dtype: _Int64Codes | type[ct.c_int64], align: bool = ..., copy: bool = ...) -> dtype[int64]: ...
@overload
- def __new__(cls, dtype: _ByteCodes | Type[ct.c_byte], align: bool = ..., copy: bool = ...) -> dtype[byte]: ...
+ def __new__(cls, dtype: _ByteCodes | type[ct.c_byte], align: bool = ..., copy: bool = ...) -> dtype[byte]: ...
@overload
- def __new__(cls, dtype: _ShortCodes | Type[ct.c_short], align: bool = ..., copy: bool = ...) -> dtype[short]: ...
+ def __new__(cls, dtype: _ShortCodes | type[ct.c_short], align: bool = ..., copy: bool = ...) -> dtype[short]: ...
@overload
- def __new__(cls, dtype: _IntCCodes | Type[ct.c_int], align: bool = ..., copy: bool = ...) -> dtype[intc]: ...
+ def __new__(cls, dtype: _IntCCodes | type[ct.c_int], align: bool = ..., copy: bool = ...) -> dtype[intc]: ...
@overload
- def __new__(cls, dtype: _IntPCodes | Type[ct.c_ssize_t], align: bool = ..., copy: bool = ...) -> dtype[intp]: ...
+ def __new__(cls, dtype: _IntPCodes | type[ct.c_ssize_t], align: bool = ..., copy: bool = ...) -> dtype[intp]: ...
@overload
- def __new__(cls, dtype: _IntCodes | Type[ct.c_long], align: bool = ..., copy: bool = ...) -> dtype[int_]: ...
+ def __new__(cls, dtype: _IntCodes | type[ct.c_long], align: bool = ..., copy: bool = ...) -> dtype[int_]: ...
@overload
- def __new__(cls, dtype: _LongLongCodes | Type[ct.c_longlong], align: bool = ..., copy: bool = ...) -> dtype[longlong]: ...
+ def __new__(cls, dtype: _LongLongCodes | type[ct.c_longlong], align: bool = ..., copy: bool = ...) -> dtype[longlong]: ...
# `floating` string-based representations and ctypes
@overload
@@ -770,11 +765,11 @@ class dtype(Generic[_DTypeScalar_co]):
@overload
def __new__(cls, dtype: _HalfCodes, align: bool = ..., copy: bool = ...) -> dtype[half]: ...
@overload
- def __new__(cls, dtype: _SingleCodes | Type[ct.c_float], align: bool = ..., copy: bool = ...) -> dtype[single]: ...
+ def __new__(cls, dtype: _SingleCodes | type[ct.c_float], align: bool = ..., copy: bool = ...) -> dtype[single]: ...
@overload
- def __new__(cls, dtype: _DoubleCodes | Type[ct.c_double], align: bool = ..., copy: bool = ...) -> dtype[double]: ...
+ def __new__(cls, dtype: _DoubleCodes | type[ct.c_double], align: bool = ..., copy: bool = ...) -> dtype[double]: ...
@overload
- def __new__(cls, dtype: _LongDoubleCodes | Type[ct.c_longdouble], align: bool = ..., copy: bool = ...) -> dtype[longdouble]: ...
+ def __new__(cls, dtype: _LongDoubleCodes | type[ct.c_longdouble], align: bool = ..., copy: bool = ...) -> dtype[longdouble]: ...
# `complexfloating` string-based representations
@overload
@@ -790,7 +785,7 @@ class dtype(Generic[_DTypeScalar_co]):
# Miscellaneous string-based representations and ctypes
@overload
- def __new__(cls, dtype: _BoolCodes | Type[ct.c_bool], align: bool = ..., copy: bool = ...) -> dtype[bool_]: ...
+ def __new__(cls, dtype: _BoolCodes | type[ct.c_bool], align: bool = ..., copy: bool = ...) -> dtype[bool_]: ...
@overload
def __new__(cls, dtype: _TD64Codes, align: bool = ..., copy: bool = ...) -> dtype[timedelta64]: ...
@overload
@@ -798,11 +793,11 @@ class dtype(Generic[_DTypeScalar_co]):
@overload
def __new__(cls, dtype: _StrCodes, align: bool = ..., copy: bool = ...) -> dtype[str_]: ...
@overload
- def __new__(cls, dtype: _BytesCodes | Type[ct.c_char], align: bool = ..., copy: bool = ...) -> dtype[bytes_]: ...
+ def __new__(cls, dtype: _BytesCodes | type[ct.c_char], align: bool = ..., copy: bool = ...) -> dtype[bytes_]: ...
@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], align: bool = ..., copy: bool = ...) -> dtype[object_]: ...
# dtype of a dtype is the same dtype
@overload
@@ -839,7 +834,7 @@ class dtype(Generic[_DTypeScalar_co]):
@overload
def __new__(
cls,
- dtype: Type[object],
+ dtype: type[object],
align: bool = ...,
copy: bool = ...,
) -> dtype[object_]: ...
@@ -848,7 +843,7 @@ class dtype(Generic[_DTypeScalar_co]):
def __class_getitem__(self, item: Any) -> GenericAlias: ...
@overload
- def __getitem__(self: dtype[void], key: List[builtins.str]) -> dtype[void]: ...
+ def __getitem__(self: dtype[void], key: list[builtins.str]) -> dtype[void]: ...
@overload
def __getitem__(self: dtype[void], key: builtins.str | SupportsIndex) -> dtype[Any]: ...
@@ -888,11 +883,11 @@ class dtype(Generic[_DTypeScalar_co]):
@property
def char(self) -> builtins.str: ...
@property
- def descr(self) -> List[Tuple[builtins.str, builtins.str] | Tuple[builtins.str, builtins.str, _Shape]]: ...
+ def descr(self) -> list[tuple[builtins.str, builtins.str] | tuple[builtins.str, builtins.str, _Shape]]: ...
@property
def fields(
self,
- ) -> None | MappingProxyType[builtins.str, Tuple[dtype[Any], int] | Tuple[dtype[Any], int, Any]]: ...
+ ) -> None | MappingProxyType[builtins.str, tuple[dtype[Any], int] | tuple[dtype[Any], int, Any]]: ...
@property
def flags(self) -> int: ...
@property
@@ -918,12 +913,12 @@ class dtype(Generic[_DTypeScalar_co]):
@property
def ndim(self) -> int: ...
@property
- def subdtype(self) -> None | Tuple[dtype[Any], _Shape]: ...
+ def subdtype(self) -> None | tuple[dtype[Any], _Shape]: ...
def newbyteorder(self: _DType, __new_order: _ByteOrder = ...) -> _DType: ...
@property
def str(self) -> builtins.str: ...
@property
- def type(self) -> Type[_DTypeScalar_co]: ...
+ def type(self) -> type[_DTypeScalar_co]: ...
_ArrayLikeInt = Union[
int,
@@ -987,7 +982,7 @@ class _ArrayOrScalarCommon:
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __copy__(self: _ArraySelf) -> _ArraySelf: ...
- def __deepcopy__(self: _ArraySelf, memo: None | Dict[int, Any], /) -> _ArraySelf: ...
+ def __deepcopy__(self: _ArraySelf, memo: None | dict[int, Any], /) -> _ArraySelf: ...
# TODO: How to deal with the non-commutative nature of `==` and `!=`?
# xref numpy/numpy#17368
@@ -1009,17 +1004,17 @@ class _ArrayOrScalarCommon:
def tolist(self) -> Any: ...
@property
- def __array_interface__(self) -> Dict[str, Any]: ...
+ def __array_interface__(self) -> dict[str, Any]: ...
@property
def __array_priority__(self) -> float: ...
@property
def __array_struct__(self) -> Any: ... # builtins.PyCapsule
- def __setstate__(self, state: Tuple[
+ def __setstate__(self, state: tuple[
SupportsIndex, # version
_ShapeLike, # Shape
_DType_co, # DType
bool, # F-continuous
- bytes | List[Any], # Data
+ bytes | list[Any], # Data
], /) -> None: ...
# a `bool_` is returned when `keepdims=True` and `self` is a 0d array
@@ -1414,12 +1409,12 @@ _SupportsBuffer = Union[
_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
_T_contra = TypeVar("_T_contra", contravariant=True)
-_2Tuple = Tuple[_T, _T]
+_2Tuple = tuple[_T, _T]
_CastingKind = L["no", "equiv", "safe", "same_kind", "unsafe"]
_DTypeLike = Union[
dtype[_ScalarType],
- Type[_ScalarType],
+ type[_ScalarType],
_SupportsDType[dtype[_ScalarType]],
]
@@ -1468,7 +1463,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
@imag.setter
def imag(self, value: ArrayLike) -> None: ...
def __new__(
- cls: Type[_ArraySelf],
+ cls: type[_ArraySelf],
shape: _ShapeLike,
dtype: DTypeLike = ...,
buffer: None | _SupportsBuffer = ...,
@@ -1507,14 +1502,14 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
def __array_wrap__(
self,
array: ndarray[_ShapeType2, _DType],
- context: None | Tuple[ufunc, Tuple[Any, ...], int] = ...,
+ context: None | tuple[ufunc, tuple[Any, ...], int] = ...,
/,
) -> ndarray[_ShapeType2, _DType]: ...
def __array_prepare__(
self,
array: ndarray[_ShapeType2, _DType],
- context: None | Tuple[ufunc, Tuple[Any, ...], int] = ...,
+ context: None | tuple[ufunc, tuple[Any, ...], int] = ...,
/,
) -> ndarray[_ShapeType2, _DType]: ...
@@ -1522,7 +1517,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
def __getitem__(self, key: (
SupportsIndex
| _ArrayLikeInt_co
- | Tuple[SupportsIndex | _ArrayLikeInt_co, ...]
+ | tuple[SupportsIndex | _ArrayLikeInt_co, ...]
)) -> Any: ...
@overload
def __getitem__(self, key: (
@@ -1531,7 +1526,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
| ellipsis
| SupportsIndex
| _ArrayLikeInt_co
- | Tuple[None | slice | ellipsis | _ArrayLikeInt_co | SupportsIndex, ...]
+ | tuple[None | slice | ellipsis | _ArrayLikeInt_co | SupportsIndex, ...]
)) -> ndarray[Any, _DType_co]: ...
@overload
def __getitem__(self: NDArray[void], key: str) -> NDArray[Any]: ...
@@ -1562,7 +1557,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
@overload
def item(
self: ndarray[Any, _dtype[_SupportsItem[_T]]], # type: ignore[type-var]
- args: Tuple[SupportsIndex, ...],
+ args: tuple[SupportsIndex, ...],
/,
) -> _T: ...
@@ -1582,7 +1577,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
def squeeze(
self,
- axis: SupportsIndex | Tuple[SupportsIndex, ...] = ...,
+ axis: SupportsIndex | tuple[SupportsIndex, ...] = ...,
) -> ndarray[Any, _DType_co]: ...
def swapaxes(
@@ -1621,7 +1616,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
def dot(self, b: ArrayLike, out: _NdArraySubClass) -> _NdArraySubClass: ...
# `nonzero()` is deprecated for 0d arrays/generics
- def nonzero(self) -> Tuple[ndarray[Any, _dtype[intp]], ...]: ...
+ def nonzero(self) -> tuple[ndarray[Any, _dtype[intp]], ...]: ...
def partition(
self,
@@ -1760,7 +1755,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
@overload
def view(self: _ArraySelf) -> _ArraySelf: ...
@overload
- def view(self, type: Type[_NdArraySubClass]) -> _NdArraySubClass: ...
+ def view(self, type: type[_NdArraySubClass]) -> _NdArraySubClass: ...
@overload
def view(self, dtype: _DTypeLike[_ScalarType]) -> NDArray[_ScalarType]: ...
@overload
@@ -1769,7 +1764,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
def view(
self,
dtype: DTypeLike,
- type: Type[_NdArraySubClass],
+ type: type[_NdArraySubClass],
) -> _NdArraySubClass: ...
@overload
@@ -1961,7 +1956,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
@overload
def __divmod__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _2Tuple[NDArray[floating[Any]]]: ... # type: ignore[misc]
@overload
- def __divmod__(self: _ArrayTD64_co, other: _SupportsArray[_dtype[timedelta64]] | _NestedSequence[_SupportsArray[_dtype[timedelta64]]]) -> Tuple[NDArray[int64], NDArray[timedelta64]]: ...
+ def __divmod__(self: _ArrayTD64_co, other: _SupportsArray[_dtype[timedelta64]] | _NestedSequence[_SupportsArray[_dtype[timedelta64]]]) -> tuple[NDArray[int64], NDArray[timedelta64]]: ...
@overload
def __rdivmod__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> _2Tuple[NDArray[int8]]: ... # type: ignore[misc]
@@ -1972,7 +1967,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
@overload
def __rdivmod__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _2Tuple[NDArray[floating[Any]]]: ... # type: ignore[misc]
@overload
- def __rdivmod__(self: _ArrayTD64_co, other: _SupportsArray[_dtype[timedelta64]] | _NestedSequence[_SupportsArray[_dtype[timedelta64]]]) -> Tuple[NDArray[int64], NDArray[timedelta64]]: ...
+ def __rdivmod__(self: _ArrayTD64_co, other: _SupportsArray[_dtype[timedelta64]] | _NestedSequence[_SupportsArray[_dtype[timedelta64]]]) -> tuple[NDArray[int64], NDArray[timedelta64]]: ...
@overload
def __add__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
@@ -2446,7 +2441,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
def __ior__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
def __dlpack__(self: NDArray[number[Any]], *, stream: None = ...) -> _PyCapsule: ...
- def __dlpack_device__(self) -> Tuple[int, L[0]]: ...
+ def __dlpack_device__(self) -> tuple[int, L[0]]: ...
# Keep `dtype` at the bottom to avoid name conflicts with `np.dtype`
@property
@@ -2478,9 +2473,9 @@ class generic(_ArrayOrScalarCommon):
@property
def size(self) -> L[1]: ...
@property
- def shape(self) -> Tuple[()]: ...
+ def shape(self) -> tuple[()]: ...
@property
- def strides(self) -> Tuple[()]: ...
+ def strides(self) -> tuple[()]: ...
def byteswap(self: _ScalarType, inplace: L[False] = ...) -> _ScalarType: ...
@property
def flat(self: _ScalarType) -> flatiter[ndarray[Any, _dtype[_ScalarType]]]: ...
@@ -2509,19 +2504,19 @@ class generic(_ArrayOrScalarCommon):
@overload
def view(
self: _ScalarType,
- type: Type[ndarray[Any, Any]] = ...,
+ type: type[ndarray[Any, Any]] = ...,
) -> _ScalarType: ...
@overload
def view(
self,
dtype: _DTypeLike[_ScalarType],
- type: Type[ndarray[Any, Any]] = ...,
+ type: type[ndarray[Any, Any]] = ...,
) -> _ScalarType: ...
@overload
def view(
self,
dtype: DTypeLike,
- type: Type[ndarray[Any, Any]] = ...,
+ type: type[ndarray[Any, Any]] = ...,
) -> Any: ...
@overload
@@ -2538,7 +2533,7 @@ class generic(_ArrayOrScalarCommon):
) -> Any: ...
def item(
- self, args: L[0] | Tuple[()] | Tuple[L[0]] = ..., /,
+ self, args: L[0] | tuple[()] | tuple[L[0]] = ..., /,
) -> Any: ...
@overload
@@ -2592,9 +2587,9 @@ class generic(_ArrayOrScalarCommon):
) -> ndarray[Any, _dtype[_ScalarType]]: ...
def squeeze(
- self: _ScalarType, axis: L[0] | Tuple[()] = ...
+ self: _ScalarType, axis: L[0] | tuple[()] = ...
) -> _ScalarType: ...
- def transpose(self: _ScalarType, axes: Tuple[()] = ..., /) -> _ScalarType: ...
+ def transpose(self: _ScalarType, axes: tuple[()] = ..., /) -> _ScalarType: ...
# Keep `dtype` at the bottom to avoid name conflicts with `np.dtype`
@property
def dtype(self: _ScalarType) -> _dtype[_ScalarType]: ...
@@ -2633,7 +2628,7 @@ class number(generic, Generic[_NBit1]): # type: ignore
class bool_(generic):
def __init__(self, value: object = ..., /) -> None: ...
def item(
- self, args: L[0] | Tuple[()] | Tuple[L[0]] = ..., /,
+ self, args: L[0] | tuple[()] | tuple[L[0]] = ..., /,
) -> bool: ...
def tolist(self) -> bool: ...
@property
@@ -2709,14 +2704,14 @@ class datetime64(generic):
def __init__(
self,
value: None | datetime64 | _CharLike_co | _DatetimeScalar = ...,
- format: _CharLike_co | Tuple[_CharLike_co, _IntLike_co] = ...,
+ format: _CharLike_co | tuple[_CharLike_co, _IntLike_co] = ...,
/,
) -> None: ...
@overload
def __init__(
self,
value: int,
- format: _CharLike_co | Tuple[_CharLike_co, _IntLike_co],
+ format: _CharLike_co | tuple[_CharLike_co, _IntLike_co],
/,
) -> None: ...
def __add__(self, other: _TD64Like_co) -> datetime64: ...
@@ -2755,7 +2750,7 @@ class integer(number[_NBit1]): # type: ignore
# NOTE: `__index__` is technically defined in the bottom-most
# sub-classes (`int64`, `uint32`, etc)
def item(
- self, args: L[0] | Tuple[()] | Tuple[L[0]] = ..., /,
+ self, args: L[0] | tuple[()] | tuple[L[0]] = ..., /,
) -> int: ...
def tolist(self) -> int: ...
def is_integer(self) -> L[True]: ...
@@ -2824,7 +2819,7 @@ class timedelta64(generic):
def __init__(
self,
value: None | int | _CharLike_co | dt.timedelta | timedelta64 = ...,
- format: _CharLike_co | Tuple[_CharLike_co, _IntLike_co] = ...,
+ format: _CharLike_co | tuple[_CharLike_co, _IntLike_co] = ...,
/,
) -> None: ...
@property
@@ -2852,8 +2847,8 @@ class timedelta64(generic):
def __rfloordiv__(self, other: timedelta64) -> int64: ...
def __mod__(self, other: timedelta64) -> timedelta64: ...
def __rmod__(self, other: timedelta64) -> timedelta64: ...
- def __divmod__(self, other: timedelta64) -> Tuple[int64, timedelta64]: ...
- def __rdivmod__(self, other: timedelta64) -> Tuple[int64, timedelta64]: ...
+ def __divmod__(self, other: timedelta64) -> tuple[int64, timedelta64]: ...
+ def __rdivmod__(self, other: timedelta64) -> tuple[int64, timedelta64]: ...
__lt__: _ComparisonOp[_TD64Like_co, _ArrayLikeTD64_co]
__le__: _ComparisonOp[_TD64Like_co, _ArrayLikeTD64_co]
__gt__: _ComparisonOp[_TD64Like_co, _ArrayLikeTD64_co]
@@ -2901,7 +2896,7 @@ uint = unsignedinteger[_NBitInt]
ulonglong = unsignedinteger[_NBitLongLong]
class inexact(number[_NBit1]): # type: ignore
- def __getnewargs__(self: inexact[_64Bit]) -> Tuple[float, ...]: ...
+ def __getnewargs__(self: inexact[_64Bit]) -> tuple[float, ...]: ...
_IntType = TypeVar("_IntType", bound=integer)
_FloatType = TypeVar('_FloatType', bound=floating)
@@ -2909,20 +2904,20 @@ _FloatType = TypeVar('_FloatType', bound=floating)
class floating(inexact[_NBit1]):
def __init__(self, value: _FloatValue = ..., /) -> None: ...
def item(
- self, args: L[0] | Tuple[()] | Tuple[L[0]] = ...,
+ self, args: L[0] | tuple[()] | tuple[L[0]] = ...,
/,
) -> float: ...
def tolist(self) -> float: ...
def is_integer(self) -> bool: ...
def hex(self: float64) -> str: ...
@classmethod
- def fromhex(cls: Type[float64], string: str, /) -> float64: ...
- def as_integer_ratio(self) -> Tuple[int, int]: ...
+ def fromhex(cls: type[float64], string: str, /) -> float64: ...
+ def as_integer_ratio(self) -> tuple[int, int]: ...
if sys.version_info >= (3, 9):
def __ceil__(self: float64) -> int: ...
def __floor__(self: float64) -> int: ...
def __trunc__(self: float64) -> int: ...
- def __getnewargs__(self: float64) -> Tuple[float]: ...
+ def __getnewargs__(self: float64) -> tuple[float]: ...
def __getformat__(self: float64, typestr: L["double", "float"], /) -> str: ...
@overload
def __round__(self, ndigits: None = ...) -> int: ...
@@ -2963,7 +2958,7 @@ longfloat = floating[_NBitLongDouble]
class complexfloating(inexact[_NBit1], Generic[_NBit1, _NBit2]):
def __init__(self, value: _ComplexValue = ..., /) -> None: ...
def item(
- self, args: L[0] | Tuple[()] | Tuple[L[0]] = ..., /,
+ self, args: L[0] | tuple[()] | tuple[L[0]] = ..., /,
) -> complex: ...
def tolist(self) -> complex: ...
@property
@@ -2971,7 +2966,7 @@ class complexfloating(inexact[_NBit1], Generic[_NBit1, _NBit2]):
@property
def imag(self) -> floating[_NBit2]: ... # type: ignore[override]
def __abs__(self) -> floating[_NBit1]: ... # type: ignore[override]
- def __getnewargs__(self: complex128) -> Tuple[float, float]: ...
+ def __getnewargs__(self: complex128) -> tuple[float, float]: ...
# NOTE: Deprecated
# def __round__(self, ndigits=...): ...
__add__: _ComplexOp[_NBit1]
@@ -3017,7 +3012,7 @@ class void(flexible):
def __getitem__(self, key: list[str]) -> void: ...
def __setitem__(
self,
- key: str | List[str] | SupportsIndex,
+ key: str | list[str] | SupportsIndex,
value: ArrayLike,
) -> None: ...
@@ -3038,7 +3033,7 @@ class bytes_(character, bytes):
self, value: str, /, encoding: str = ..., errors: str = ...
) -> None: ...
def item(
- self, args: L[0] | Tuple[()] | Tuple[L[0]] = ..., /,
+ self, args: L[0] | tuple[()] | tuple[L[0]] = ..., /,
) -> bytes: ...
def tolist(self) -> bytes: ...
@@ -3053,7 +3048,7 @@ class str_(character, str):
self, value: bytes, /, encoding: str = ..., errors: str = ...
) -> None: ...
def item(
- self, args: L[0] | Tuple[()] | Tuple[L[0]] = ..., /,
+ self, args: L[0] | tuple[()] | tuple[L[0]] = ..., /,
) -> str: ...
def tolist(self) -> str: ...
@@ -3128,7 +3123,7 @@ class ufunc:
@property
def ntypes(self) -> int: ...
@property
- def types(self) -> List[str]: ...
+ def types(self) -> list[str]: ...
# Broad return type because it has to encompass things like
#
# >>> np.logical_and.identity is True
@@ -3292,7 +3287,7 @@ class errstate(Generic[_CallType], ContextDecorator):
def __enter__(self) -> None: ...
def __exit__(
self,
- exc_type: None | Type[BaseException],
+ exc_type: None | type[BaseException],
exc_value: None | BaseException,
traceback: None | TracebackType,
/,
@@ -3316,7 +3311,7 @@ class ndenumerate(Generic[_ScalarType]):
def __new__(cls, arr: float | _NestedSequence[float]) -> ndenumerate[float_]: ...
@overload
def __new__(cls, arr: complex | _NestedSequence[complex]) -> ndenumerate[complex_]: ...
- def __next__(self: ndenumerate[_ScalarType]) -> Tuple[_Shape, _ScalarType]: ...
+ def __next__(self: ndenumerate[_ScalarType]) -> tuple[_Shape, _ScalarType]: ...
def __iter__(self: _T) -> _T: ...
class ndindex:
@@ -3351,7 +3346,7 @@ class broadcast:
@property
def index(self) -> int: ...
@property
- def iters(self) -> Tuple[flatiter[Any], ...]: ...
+ def iters(self) -> tuple[flatiter[Any], ...]: ...
@property
def nd(self) -> int: ...
@property
@@ -3362,7 +3357,7 @@ class broadcast:
def shape(self) -> _Shape: ...
@property
def size(self) -> int: ...
- def __next__(self) -> Tuple[Any, ...]: ...
+ def __next__(self) -> tuple[Any, ...]: ...
def __iter__(self: _T) -> _T: ...
def reset(self) -> None: ...
@@ -3404,7 +3399,7 @@ class finfo(Generic[_FloatType]):
) -> finfo[floating[_NBit1]]: ...
@overload
def __new__(
- cls, dtype: complex | float | Type[complex] | Type[float]
+ cls, dtype: complex | float | type[complex] | type[float]
) -> finfo[float_]: ...
@overload
def __new__(
@@ -3424,7 +3419,7 @@ class iinfo(Generic[_IntType]):
@overload
def __new__(cls, dtype: _IntType | _DTypeLike[_IntType]) -> iinfo[_IntType]: ...
@overload
- def __new__(cls, dtype: int | Type[int]) -> iinfo[int_]: ...
+ def __new__(cls, dtype: int | type[int]) -> iinfo[int_]: ...
@overload
def __new__(cls, dtype: str) -> iinfo[Any]: ...
@@ -3481,7 +3476,7 @@ class recarray(ndarray[_ShapeType, _DType_co]):
def __getitem__(self, indx: (
SupportsIndex
| _ArrayLikeInt_co
- | Tuple[SupportsIndex | _ArrayLikeInt_co, ...]
+ | tuple[SupportsIndex | _ArrayLikeInt_co, ...]
)) -> Any: ...
@overload
def __getitem__(self: recarray[Any, dtype[void]], indx: (
@@ -3490,7 +3485,7 @@ class recarray(ndarray[_ShapeType, _DType_co]):
| ellipsis
| SupportsIndex
| _ArrayLikeInt_co
- | Tuple[None | slice | ellipsis | _ArrayLikeInt_co | SupportsIndex, ...]
+ | tuple[None | slice | ellipsis | _ArrayLikeInt_co | SupportsIndex, ...]
)) -> recarray[Any, _DType_co]: ...
@overload
def __getitem__(self, indx: (
@@ -3499,7 +3494,7 @@ class recarray(ndarray[_ShapeType, _DType_co]):
| ellipsis
| SupportsIndex
| _ArrayLikeInt_co
- | Tuple[None | slice | ellipsis | _ArrayLikeInt_co | SupportsIndex, ...]
+ | tuple[None | slice | ellipsis | _ArrayLikeInt_co | SupportsIndex, ...]
)) -> ndarray[Any, _DType_co]: ...
@overload
def __getitem__(self, indx: str) -> NDArray[Any]: ...
@@ -3570,18 +3565,18 @@ class nditer:
def __enter__(self) -> nditer: ...
def __exit__(
self,
- exc_type: None | Type[BaseException],
+ exc_type: None | type[BaseException],
exc_value: None | BaseException,
traceback: None | TracebackType,
) -> None: ...
def __iter__(self) -> nditer: ...
- def __next__(self) -> Tuple[NDArray[Any], ...]: ...
+ def __next__(self) -> tuple[NDArray[Any], ...]: ...
def __len__(self) -> int: ...
def __copy__(self) -> nditer: ...
@overload
def __getitem__(self, index: SupportsIndex) -> NDArray[Any]: ...
@overload
- def __getitem__(self, index: slice) -> Tuple[NDArray[Any], ...]: ...
+ def __getitem__(self, index: slice) -> tuple[NDArray[Any], ...]: ...
def __setitem__(self, index: slice | SupportsIndex, value: ArrayLike) -> None: ...
def close(self) -> None: ...
def copy(self) -> nditer: ...
@@ -3592,7 +3587,7 @@ class nditer:
def remove_multi_index(self) -> None: ...
def reset(self) -> None: ...
@property
- def dtypes(self) -> Tuple[dtype[Any], ...]: ...
+ def dtypes(self) -> tuple[dtype[Any], ...]: ...
@property
def finished(self) -> bool: ...
@property
@@ -3608,23 +3603,23 @@ class nditer:
@property
def iterindex(self) -> int: ...
@property
- def iterrange(self) -> Tuple[int, ...]: ...
+ def iterrange(self) -> tuple[int, ...]: ...
@property
def itersize(self) -> int: ...
@property
- def itviews(self) -> Tuple[NDArray[Any], ...]: ...
+ def itviews(self) -> tuple[NDArray[Any], ...]: ...
@property
- def multi_index(self) -> Tuple[int, ...]: ...
+ def multi_index(self) -> tuple[int, ...]: ...
@property
def ndim(self) -> int: ...
@property
def nop(self) -> int: ...
@property
- def operands(self) -> Tuple[NDArray[Any], ...]: ...
+ def operands(self) -> tuple[NDArray[Any], ...]: ...
@property
- def shape(self) -> Tuple[int, ...]: ...
+ def shape(self) -> tuple[int, ...]: ...
@property
- def value(self) -> Tuple[NDArray[Any], ...]: ...
+ def value(self) -> tuple[NDArray[Any], ...]: ...
_MemMapModeKind = L[
"readonly", "r",
@@ -3642,10 +3637,10 @@ class memmap(ndarray[_ShapeType, _DType_co]):
def __new__(
subtype,
filename: str | bytes | os.PathLike[str] | os.PathLike[bytes] | _MemMapIOProtocol,
- dtype: Type[uint8] = ...,
+ dtype: type[uint8] = ...,
mode: _MemMapModeKind = ...,
offset: int = ...,
- shape: None | int | Tuple[int, ...] = ...,
+ shape: None | int | tuple[int, ...] = ...,
order: _OrderKACF = ...,
) -> memmap[Any, dtype[uint8]]: ...
@overload
@@ -3655,7 +3650,7 @@ class memmap(ndarray[_ShapeType, _DType_co]):
dtype: _DTypeLike[_ScalarType],
mode: _MemMapModeKind = ...,
offset: int = ...,
- shape: None | int | Tuple[int, ...] = ...,
+ shape: None | int | tuple[int, ...] = ...,
order: _OrderKACF = ...,
) -> memmap[Any, dtype[_ScalarType]]: ...
@overload
@@ -3665,14 +3660,14 @@ class memmap(ndarray[_ShapeType, _DType_co]):
dtype: DTypeLike,
mode: _MemMapModeKind = ...,
offset: int = ...,
- shape: None | int | Tuple[int, ...] = ...,
+ shape: None | int | tuple[int, ...] = ...,
order: _OrderKACF = ...,
) -> memmap[Any, dtype[Any]]: ...
def __array_finalize__(self, obj: memmap[Any, Any]) -> None: ...
def __array_wrap__(
self,
array: memmap[_ShapeType, _DType_co],
- context: None | Tuple[ufunc, Tuple[Any, ...], int] = ...,
+ context: None | tuple[ufunc, tuple[Any, ...], int] = ...,
) -> Any: ...
def flush(self) -> None: ...
@@ -3681,7 +3676,7 @@ class vectorize:
cache: bool
signature: None | str
otypes: None | str
- excluded: Set[int | str]
+ excluded: set[int | str]
__doc__: None | str
def __init__(
self,
@@ -3784,7 +3779,7 @@ class matrix(ndarray[_ShapeType, _DType_co]):
def __getitem__(self, key: (
SupportsIndex
| _ArrayLikeInt_co
- | Tuple[SupportsIndex | _ArrayLikeInt_co, ...]
+ | tuple[SupportsIndex | _ArrayLikeInt_co, ...]
)) -> Any: ...
@overload
def __getitem__(self, key: (
@@ -3793,7 +3788,7 @@ class matrix(ndarray[_ShapeType, _DType_co]):
| ellipsis
| SupportsIndex
| _ArrayLikeInt_co
- | Tuple[None | slice | ellipsis | _ArrayLikeInt_co | SupportsIndex, ...]
+ | tuple[None | slice | ellipsis | _ArrayLikeInt_co | SupportsIndex, ...]
)) -> matrix[Any, _DType_co]: ...
@overload
def __getitem__(self: NDArray[void], key: str) -> matrix[Any, dtype[Any]]: ...
@@ -3891,7 +3886,7 @@ class matrix(ndarray[_ShapeType, _DType_co]):
def ptp(self, axis: None | _ShapeLike = ..., out: _NdArraySubClass = ...) -> _NdArraySubClass: ...
def squeeze(self, axis: None | _ShapeLike = ...) -> matrix[Any, _DType_co]: ...
- def tolist(self: matrix[Any, dtype[_SupportsItem[_T]]]) -> List[List[_T]]: ... # type: ignore[typevar]
+ def tolist(self: matrix[Any, dtype[_SupportsItem[_T]]]) -> list[list[_T]]: ... # type: ignore[typevar]
def ravel(self, order: _OrderKACF = ...) -> matrix[Any, _DType_co]: ...
def flatten(self, order: _OrderKACF = ...) -> matrix[Any, _DType_co]: ...
diff --git a/numpy/_pytesttester.pyi b/numpy/_pytesttester.pyi
index 0be64b3f7..383f2616d 100644
--- a/numpy/_pytesttester.pyi
+++ b/numpy/_pytesttester.pyi
@@ -1,6 +1,6 @@
-from typing import List, Iterable, Literal as L
+from typing import Iterable, Literal as L
-__all__: List[str]
+__all__: list[str]
class PytestTester:
module_name: str
diff --git a/numpy/core/_internal.pyi b/numpy/core/_internal.pyi
index 51b2a87dd..8a25ef2cb 100644
--- a/numpy/core/_internal.pyi
+++ b/numpy/core/_internal.pyi
@@ -1,4 +1,4 @@
-from typing import Any, TypeVar, Type, overload, Generic
+from typing import Any, TypeVar, overload, Generic
import ctypes as ct
from numpy import ndarray
@@ -25,6 +25,6 @@ class _ctypes(Generic[_PT]):
@property
def _as_parameter_(self) -> ct.c_void_p: ...
- def data_as(self, obj: Type[_CastT]) -> _CastT: ...
- def shape_as(self, obj: Type[_CT]) -> ct.Array[_CT]: ...
- def strides_as(self, obj: Type[_CT]) -> ct.Array[_CT]: ...
+ def data_as(self, obj: type[_CastT]) -> _CastT: ...
+ def shape_as(self, obj: type[_CT]) -> ct.Array[_CT]: ...
+ def strides_as(self, obj: type[_CT]) -> ct.Array[_CT]: ...
diff --git a/numpy/core/_type_aliases.pyi b/numpy/core/_type_aliases.pyi
index 660b1d2b6..bbead0cb5 100644
--- a/numpy/core/_type_aliases.pyi
+++ b/numpy/core/_type_aliases.pyi
@@ -1,13 +1,13 @@
-from typing import Dict, Type, List, TypedDict
+from typing import 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]]
- others: List[type]
+ int: list[type[signedinteger]]
+ uint: list[type[unsignedinteger]]
+ float: list[type[floating]]
+ complex: list[type[complexfloating]]
+ others: list[type]
-sctypeDict: Dict[int | str, Type[generic]]
+sctypeDict: dict[int | str, type[generic]]
sctypes: _SCTypes
diff --git a/numpy/core/arrayprint.pyi b/numpy/core/arrayprint.pyi
index 5c33a21d3..acbec84e4 100644
--- a/numpy/core/arrayprint.pyi
+++ b/numpy/core/arrayprint.pyi
@@ -1,5 +1,5 @@
from types import TracebackType
-from typing import Any, Callable, Type, Literal, TypedDict, SupportsIndex
+from typing import Any, Callable, Literal, TypedDict, SupportsIndex
# Using a private class is by no means ideal, but it is simply a consequence
# of a `contextlib.context` returning an instance of aforementioned class
diff --git a/numpy/core/defchararray.pyi b/numpy/core/defchararray.pyi
index 28d247b05..250706eb1 100644
--- a/numpy/core/defchararray.pyi
+++ b/numpy/core/defchararray.pyi
@@ -3,7 +3,6 @@ from typing import (
overload,
TypeVar,
Any,
- List,
)
from numpy import (
@@ -30,7 +29,7 @@ from numpy.core.multiarray import compare_chararrays as compare_chararrays
_SCT = TypeVar("_SCT", str_, bytes_)
_CharArray = chararray[Any, dtype[_SCT]]
-__all__: List[str]
+__all__: list[str]
# Comparison
@overload
diff --git a/numpy/core/einsumfunc.pyi b/numpy/core/einsumfunc.pyi
index ec34c3c92..24c6d3228 100644
--- a/numpy/core/einsumfunc.pyi
+++ b/numpy/core/einsumfunc.pyi
@@ -1,4 +1,4 @@
-from typing import List, TypeVar, Any, overload, Union, Tuple, Sequence, Literal
+from typing import TypeVar, Any, overload, Union, Sequence, Literal
from numpy import (
ndarray,
@@ -34,7 +34,7 @@ _OptimizeKind = None | bool | Literal["greedy", "optimal"] | Sequence[Any]
_CastingSafe = Literal["no", "equiv", "safe", "same_kind"]
_CastingUnsafe = Literal["unsafe"]
-__all__: List[str]
+__all__: list[str]
# TODO: Properly handle the `casting`-based combinatorics
# TODO: We need to evaluate the content `__subscripts` in order
@@ -140,4 +140,4 @@ def einsum_path(
/,
*operands: _ArrayLikeComplex_co,
optimize: _OptimizeKind = ...,
-) -> Tuple[List[Any], str]: ...
+) -> tuple[list[Any], str]: ...
diff --git a/numpy/core/fromnumeric.pyi b/numpy/core/fromnumeric.pyi
index 12847ae4f..591f9b3c0 100644
--- a/numpy/core/fromnumeric.pyi
+++ b/numpy/core/fromnumeric.pyi
@@ -1,5 +1,5 @@
import datetime as dt
-from typing import Union, Sequence, Tuple, Any, overload, TypeVar, Literal
+from typing import Union, Sequence, Any, overload, TypeVar, Literal
from numpy import (
ndarray,
@@ -203,7 +203,7 @@ def trace(
def ravel(a: ArrayLike, order: _OrderKACF = ...) -> ndarray: ...
-def nonzero(a: ArrayLike) -> Tuple[ndarray, ...]: ...
+def nonzero(a: ArrayLike) -> tuple[ndarray, ...]: ...
def shape(a: ArrayLike) -> _Shape: ...
diff --git a/numpy/core/function_base.pyi b/numpy/core/function_base.pyi
index 6e0843a0e..b21892177 100644
--- a/numpy/core/function_base.pyi
+++ b/numpy/core/function_base.pyi
@@ -1,12 +1,9 @@
from typing import (
Literal as L,
overload,
- Tuple,
Union,
Any,
SupportsIndex,
- List,
- Type,
TypeVar,
)
@@ -26,11 +23,11 @@ _SCT = TypeVar("_SCT", bound=generic)
_DTypeLike = Union[
dtype[_SCT],
- Type[_SCT],
+ type[_SCT],
_SupportsDType[dtype[_SCT]],
]
-__all__: List[str]
+__all__: list[str]
@overload
def linspace(
@@ -81,7 +78,7 @@ def linspace(
retstep: L[True] = ...,
dtype: None = ...,
axis: SupportsIndex = ...,
-) -> Tuple[NDArray[floating[Any]], floating[Any]]: ...
+) -> tuple[NDArray[floating[Any]], floating[Any]]: ...
@overload
def linspace(
start: _ArrayLikeComplex_co,
@@ -91,7 +88,7 @@ def linspace(
retstep: L[True] = ...,
dtype: None = ...,
axis: SupportsIndex = ...,
-) -> Tuple[NDArray[complexfloating[Any, Any]], complexfloating[Any, Any]]: ...
+) -> tuple[NDArray[complexfloating[Any, Any]], complexfloating[Any, Any]]: ...
@overload
def linspace(
start: _ArrayLikeComplex_co,
@@ -101,7 +98,7 @@ def linspace(
retstep: L[True] = ...,
dtype: _DTypeLike[_SCT] = ...,
axis: SupportsIndex = ...,
-) -> Tuple[NDArray[_SCT], _SCT]: ...
+) -> tuple[NDArray[_SCT], _SCT]: ...
@overload
def linspace(
start: _ArrayLikeComplex_co,
@@ -111,7 +108,7 @@ def linspace(
retstep: L[True] = ...,
dtype: DTypeLike = ...,
axis: SupportsIndex = ...,
-) -> Tuple[NDArray[Any], Any]: ...
+) -> tuple[NDArray[Any], Any]: ...
@overload
def logspace(
@@ -195,6 +192,6 @@ def geomspace(
def add_newdoc(
place: str,
obj: str,
- doc: str | Tuple[str, str] | List[Tuple[str, str]],
+ doc: str | tuple[str, str] | list[tuple[str, str]],
warn_on_python: bool = ...,
) -> None: ...
diff --git a/numpy/core/getlimits.pyi b/numpy/core/getlimits.pyi
index 66d062995..da5e3c23e 100644
--- a/numpy/core/getlimits.pyi
+++ b/numpy/core/getlimits.pyi
@@ -1,8 +1,6 @@
-from typing import List
-
from numpy import (
finfo as finfo,
iinfo as iinfo,
)
-__all__: List[str]
+__all__: list[str]
diff --git a/numpy/core/memmap.pyi b/numpy/core/memmap.pyi
index ba595bf1e..03c6b772d 100644
--- a/numpy/core/memmap.pyi
+++ b/numpy/core/memmap.pyi
@@ -1,5 +1,3 @@
-from typing import List
-
from numpy import memmap as memmap
-__all__: List[str]
+__all__: list[str]
diff --git a/numpy/core/multiarray.pyi b/numpy/core/multiarray.pyi
index b410ffe21..b8816bd26 100644
--- a/numpy/core/multiarray.pyi
+++ b/numpy/core/multiarray.pyi
@@ -9,11 +9,8 @@ from typing import (
Iterable,
overload,
TypeVar,
- List,
- Type,
Union,
Sequence,
- Tuple,
SupportsIndex,
final,
Final,
@@ -89,7 +86,7 @@ _ArrayType = TypeVar("_ArrayType", bound=NDArray[Any])
# Subscriptable subsets of `npt.DTypeLike` and `npt.ArrayLike`
_DTypeLike = Union[
dtype[_SCT],
- Type[_SCT],
+ type[_SCT],
_SupportsDType[dtype[_SCT]],
]
_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
@@ -119,7 +116,7 @@ _RollKind = L[ # `raise` is deliberately excluded
"modifiedpreceding",
]
-__all__: List[str]
+__all__: list[str]
ALLOW_THREADS: Final[int] # 0 or 1 (system-specific)
BUFSIZE: L[8192]
@@ -283,26 +280,26 @@ def unravel_index( # type: ignore[misc]
indices: _IntLike_co,
shape: _ShapeLike,
order: _OrderCF = ...,
-) -> Tuple[intp, ...]: ...
+) -> tuple[intp, ...]: ...
@overload
def unravel_index(
indices: _ArrayLikeInt_co,
shape: _ShapeLike,
order: _OrderCF = ...,
-) -> Tuple[NDArray[intp], ...]: ...
+) -> tuple[NDArray[intp], ...]: ...
@overload
def ravel_multi_index( # type: ignore[misc]
multi_index: Sequence[_IntLike_co],
dims: Sequence[SupportsIndex],
- mode: _ModeKind | Tuple[_ModeKind, ...] = ...,
+ mode: _ModeKind | tuple[_ModeKind, ...] = ...,
order: _OrderCF = ...,
) -> intp: ...
@overload
def ravel_multi_index(
multi_index: Sequence[_ArrayLikeInt_co],
dims: Sequence[SupportsIndex],
- mode: _ModeKind | Tuple[_ModeKind, ...] = ...,
+ mode: _ModeKind | tuple[_ModeKind, ...] = ...,
order: _OrderCF = ...,
) -> NDArray[intp]: ...
@@ -367,7 +364,7 @@ def inner(
def where(
condition: ArrayLike,
/,
-) -> Tuple[NDArray[intp], ...]: ...
+) -> tuple[NDArray[intp], ...]: ...
@overload
def where(
condition: ArrayLike,
@@ -598,10 +595,10 @@ def asfortranarray(
like: ArrayLike = ...,
) -> NDArray[Any]: ...
-# In practice `List[Any]` is list with an int, int and a valid
+# In practice `list[Any]` is list with an int, int and a valid
# `np.seterrcall()` object
-def geterrobj() -> List[Any]: ...
-def seterrobj(errobj: List[Any], /) -> None: ...
+def geterrobj() -> list[Any]: ...
+def seterrobj(errobj: list[Any], /) -> None: ...
def promote_types(__type1: DTypeLike, __type2: DTypeLike) -> dtype[Any]: ...
@@ -810,7 +807,7 @@ def arange(
def datetime_data(
dtype: str | _DTypeLike[datetime64] | _DTypeLike[timedelta64], /,
-) -> Tuple[str, int]: ...
+) -> tuple[str, int]: ...
# The datetime functions perform unsafe casts to `datetime64[D]`,
# so a lot of different argument types are allowed here
@@ -1023,4 +1020,4 @@ def nested_iters(
order: _OrderKACF = ...,
casting: _CastingKind = ...,
buffersize: SupportsIndex = ...,
-) -> Tuple[nditer, ...]: ...
+) -> tuple[nditer, ...]: ...
diff --git a/numpy/core/numeric.pyi b/numpy/core/numeric.pyi
index d7ec30351..a8727b1ce 100644
--- a/numpy/core/numeric.pyi
+++ b/numpy/core/numeric.pyi
@@ -2,13 +2,10 @@ from typing import (
Any,
Union,
Sequence,
- Tuple,
Callable,
- List,
overload,
TypeVar,
Literal,
- Type,
SupportsAbs,
SupportsIndex,
NoReturn,
@@ -57,13 +54,13 @@ _ArrayType = TypeVar("_ArrayType", bound=NDArray[Any])
_DTypeLike = Union[
dtype[_SCT],
- Type[_SCT],
+ type[_SCT],
_SupportsDType[dtype[_SCT]],
]
_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
_CorrelateMode = Literal["valid", "same", "full"]
-__all__: List[str]
+__all__: list[str]
@overload
def zeros_like(
@@ -406,43 +403,43 @@ def outer(
def tensordot(
a: _ArrayLikeBool_co,
b: _ArrayLikeBool_co,
- axes: int | Tuple[_ShapeLike, _ShapeLike] = ...,
+ axes: int | tuple[_ShapeLike, _ShapeLike] = ...,
) -> NDArray[bool_]: ...
@overload
def tensordot(
a: _ArrayLikeUInt_co,
b: _ArrayLikeUInt_co,
- axes: int | Tuple[_ShapeLike, _ShapeLike] = ...,
+ axes: int | tuple[_ShapeLike, _ShapeLike] = ...,
) -> NDArray[unsignedinteger[Any]]: ...
@overload
def tensordot(
a: _ArrayLikeInt_co,
b: _ArrayLikeInt_co,
- axes: int | Tuple[_ShapeLike, _ShapeLike] = ...,
+ axes: int | tuple[_ShapeLike, _ShapeLike] = ...,
) -> NDArray[signedinteger[Any]]: ...
@overload
def tensordot(
a: _ArrayLikeFloat_co,
b: _ArrayLikeFloat_co,
- axes: int | Tuple[_ShapeLike, _ShapeLike] = ...,
+ axes: int | tuple[_ShapeLike, _ShapeLike] = ...,
) -> NDArray[floating[Any]]: ...
@overload
def tensordot(
a: _ArrayLikeComplex_co,
b: _ArrayLikeComplex_co,
- axes: int | Tuple[_ShapeLike, _ShapeLike] = ...,
+ axes: int | tuple[_ShapeLike, _ShapeLike] = ...,
) -> NDArray[complexfloating[Any, Any]]: ...
@overload
def tensordot(
a: _ArrayLikeTD64_co,
b: _ArrayLikeTD64_co,
- axes: int | Tuple[_ShapeLike, _ShapeLike] = ...,
+ axes: int | tuple[_ShapeLike, _ShapeLike] = ...,
) -> NDArray[timedelta64]: ...
@overload
def tensordot(
a: _ArrayLikeObject_co,
b: _ArrayLikeObject_co,
- axes: int | Tuple[_ShapeLike, _ShapeLike] = ...,
+ axes: int | tuple[_ShapeLike, _ShapeLike] = ...,
) -> NDArray[object_]: ...
@overload
@@ -528,15 +525,15 @@ def cross(
@overload
def indices(
dimensions: Sequence[int],
- dtype: Type[int] = ...,
+ dtype: type[int] = ...,
sparse: Literal[False] = ...,
) -> NDArray[int_]: ...
@overload
def indices(
dimensions: Sequence[int],
- dtype: Type[int] = ...,
+ dtype: type[int] = ...,
sparse: Literal[True] = ...,
-) -> Tuple[NDArray[int_], ...]: ...
+) -> tuple[NDArray[int_], ...]: ...
@overload
def indices(
dimensions: Sequence[int],
@@ -548,7 +545,7 @@ def indices(
dimensions: Sequence[int],
dtype: _DTypeLike[_SCT],
sparse: Literal[True],
-) -> Tuple[NDArray[_SCT], ...]: ...
+) -> tuple[NDArray[_SCT], ...]: ...
@overload
def indices(
dimensions: Sequence[int],
@@ -560,7 +557,7 @@ def indices(
dimensions: Sequence[int],
dtype: DTypeLike,
sparse: Literal[True],
-) -> Tuple[NDArray[Any], ...]: ...
+) -> tuple[NDArray[Any], ...]: ...
def fromfunction(
function: Callable[..., _T],
diff --git a/numpy/core/numerictypes.pyi b/numpy/core/numerictypes.pyi
index 1d3ff773b..1ad7dc7ce 100644
--- a/numpy/core/numerictypes.pyi
+++ b/numpy/core/numerictypes.pyi
@@ -2,14 +2,10 @@ import sys
import types
from typing import (
Literal as L,
- Type,
Union,
- Tuple,
overload,
Any,
TypeVar,
- Dict,
- List,
Iterable,
Protocol,
TypedDict,
@@ -57,7 +53,7 @@ _SCT = TypeVar("_SCT", bound=generic)
# A paramtrizable subset of `npt.DTypeLike`
_DTypeLike = Union[
- Type[_SCT],
+ type[_SCT],
dtype[_SCT],
_SupportsDType[dtype[_SCT]],
]
@@ -78,48 +74,48 @@ class _TypeCodes(TypedDict):
Datetime: L['Mm']
All: L['?bhilqpBHILQPefdgFDGSUVOMm']
-class _typedict(Dict[Type[generic], _T]):
+class _typedict(dict[type[generic], _T]):
def __getitem__(self, key: DTypeLike) -> _T: ...
if sys.version_info >= (3, 10):
_TypeTuple = Union[
- Type[Any],
+ type[Any],
types.UnionType,
- Tuple[Union[Type[Any], types.UnionType, Tuple[Any, ...]], ...],
+ tuple[Union[type[Any], types.UnionType, tuple[Any, ...]], ...],
]
else:
_TypeTuple = Union[
- Type[Any],
- Tuple[Union[Type[Any], Tuple[Any, ...]], ...],
+ type[Any],
+ tuple[Union[type[Any], tuple[Any, ...]], ...],
]
-__all__: List[str]
+__all__: list[str]
@overload
-def maximum_sctype(t: _DTypeLike[_SCT]) -> Type[_SCT]: ...
+def maximum_sctype(t: _DTypeLike[_SCT]) -> type[_SCT]: ...
@overload
-def maximum_sctype(t: DTypeLike) -> Type[Any]: ...
+def maximum_sctype(t: DTypeLike) -> type[Any]: ...
@overload
-def issctype(rep: dtype[Any] | Type[Any]) -> bool: ...
+def issctype(rep: dtype[Any] | type[Any]) -> bool: ...
@overload
def issctype(rep: object) -> L[False]: ...
@overload
-def obj2sctype(rep: _DTypeLike[_SCT], default: None = ...) -> None | Type[_SCT]: ...
+def obj2sctype(rep: _DTypeLike[_SCT], default: None = ...) -> None | type[_SCT]: ...
@overload
-def obj2sctype(rep: _DTypeLike[_SCT], default: _T) -> _T | Type[_SCT]: ...
+def obj2sctype(rep: _DTypeLike[_SCT], default: _T) -> _T | type[_SCT]: ...
@overload
-def obj2sctype(rep: DTypeLike, default: None = ...) -> None | Type[Any]: ...
+def obj2sctype(rep: DTypeLike, default: None = ...) -> None | type[Any]: ...
@overload
-def obj2sctype(rep: DTypeLike, default: _T) -> _T | Type[Any]: ...
+def obj2sctype(rep: DTypeLike, default: _T) -> _T | type[Any]: ...
@overload
def obj2sctype(rep: object, default: None = ...) -> None: ...
@overload
def obj2sctype(rep: object, default: _T) -> _T: ...
@overload
-def issubclass_(arg1: Type[Any], arg2: _TypeTuple) -> bool: ...
+def issubclass_(arg1: type[Any], arg2: _TypeTuple) -> bool: ...
@overload
def issubclass_(arg1: object, arg2: object) -> L[False]: ...
@@ -137,37 +133,37 @@ def find_common_type(
cast: _typedict[_CastFunc]
nbytes: _typedict[int]
typecodes: _TypeCodes
-ScalarType: Tuple[
- Type[int],
- Type[float],
- Type[complex],
- Type[int],
- Type[bool],
- Type[bytes],
- Type[str],
- Type[memoryview],
- Type[bool_],
- Type[csingle],
- Type[cdouble],
- Type[clongdouble],
- Type[half],
- Type[single],
- Type[double],
- Type[longdouble],
- Type[byte],
- Type[short],
- Type[intc],
- Type[int_],
- Type[longlong],
- Type[timedelta64],
- Type[datetime64],
- Type[object_],
- Type[bytes_],
- Type[str_],
- Type[ubyte],
- Type[ushort],
- Type[uintc],
- Type[uint],
- Type[ulonglong],
- Type[void],
+ScalarType: tuple[
+ type[int],
+ type[float],
+ type[complex],
+ type[int],
+ type[bool],
+ type[bytes],
+ type[str],
+ type[memoryview],
+ type[bool_],
+ type[csingle],
+ type[cdouble],
+ type[clongdouble],
+ type[half],
+ type[single],
+ type[double],
+ type[longdouble],
+ type[byte],
+ type[short],
+ type[intc],
+ type[int_],
+ type[longlong],
+ type[timedelta64],
+ type[datetime64],
+ type[object_],
+ type[bytes_],
+ type[str_],
+ type[ubyte],
+ type[ushort],
+ type[uintc],
+ type[uint],
+ type[ulonglong],
+ type[void],
]
diff --git a/numpy/core/records.pyi b/numpy/core/records.pyi
index 172bab3ee..1e837b492 100644
--- a/numpy/core/records.pyi
+++ b/numpy/core/records.pyi
@@ -1,12 +1,10 @@
import os
from typing import (
- List,
Sequence,
Any,
TypeVar,
Iterable,
overload,
- Tuple,
Protocol,
)
@@ -39,7 +37,7 @@ class _SupportsReadInto(Protocol):
def tell(self, /) -> int: ...
def readinto(self, buffer: memoryview, /) -> int: ...
-__all__: List[str]
+__all__: list[str]
@overload
def fromarrays(
@@ -67,7 +65,7 @@ def fromarrays(
@overload
def fromrecords(
- recList: _ArrayLikeVoid_co | Tuple[Any, ...] | _NestedSequence[Tuple[Any, ...]],
+ recList: _ArrayLikeVoid_co | tuple[Any, ...] | _NestedSequence[tuple[Any, ...]],
dtype: DTypeLike = ...,
shape: None | _ShapeLike = ...,
formats: None = ...,
@@ -78,7 +76,7 @@ def fromrecords(
) -> _RecArray[record]: ...
@overload
def fromrecords(
- recList: _ArrayLikeVoid_co | Tuple[Any, ...] | _NestedSequence[Tuple[Any, ...]],
+ recList: _ArrayLikeVoid_co | tuple[Any, ...] | _NestedSequence[tuple[Any, ...]],
dtype: None = ...,
shape: None | _ShapeLike = ...,
*,
diff --git a/numpy/core/shape_base.pyi b/numpy/core/shape_base.pyi
index 159ad2781..f0f0f6f56 100644
--- a/numpy/core/shape_base.pyi
+++ b/numpy/core/shape_base.pyi
@@ -1,4 +1,4 @@
-from typing import TypeVar, overload, List, Sequence, Any, SupportsIndex
+from typing import TypeVar, overload, Sequence, Any, SupportsIndex
from numpy import generic, dtype
from numpy.typing import ArrayLike, NDArray, _FiniteNestedSequence, _SupportsArray
@@ -8,28 +8,28 @@ _ArrayType = TypeVar("_ArrayType", bound=NDArray[Any])
_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
-__all__: List[str]
+__all__: list[str]
@overload
def atleast_1d(arys: _ArrayLike[_SCT], /) -> NDArray[_SCT]: ...
@overload
def atleast_1d(arys: ArrayLike, /) -> NDArray[Any]: ...
@overload
-def atleast_1d(*arys: ArrayLike) -> List[NDArray[Any]]: ...
+def atleast_1d(*arys: ArrayLike) -> list[NDArray[Any]]: ...
@overload
def atleast_2d(arys: _ArrayLike[_SCT], /) -> NDArray[_SCT]: ...
@overload
def atleast_2d(arys: ArrayLike, /) -> NDArray[Any]: ...
@overload
-def atleast_2d(*arys: ArrayLike) -> List[NDArray[Any]]: ...
+def atleast_2d(*arys: ArrayLike) -> list[NDArray[Any]]: ...
@overload
def atleast_3d(arys: _ArrayLike[_SCT], /) -> NDArray[_SCT]: ...
@overload
def atleast_3d(arys: ArrayLike, /) -> NDArray[Any]: ...
@overload
-def atleast_3d(*arys: ArrayLike) -> List[NDArray[Any]]: ...
+def atleast_3d(*arys: ArrayLike) -> list[NDArray[Any]]: ...
@overload
def vstack(tup: Sequence[_ArrayLike[_SCT]]) -> NDArray[_SCT]: ...
diff --git a/numpy/ctypeslib.pyi b/numpy/ctypeslib.pyi
index 62aa374b6..892d4b7e2 100644
--- a/numpy/ctypeslib.pyi
+++ b/numpy/ctypeslib.pyi
@@ -8,17 +8,13 @@ import ctypes
from typing import (
Literal as L,
Any,
- List,
Union,
TypeVar,
- Type,
Generic,
overload,
Iterable,
ClassVar,
- Tuple,
Sequence,
- Dict,
)
from numpy import (
@@ -81,7 +77,7 @@ _SCT = TypeVar("_SCT", bound=generic)
_DTypeLike = Union[
dtype[_SCT],
- Type[_SCT],
+ type[_SCT],
_SupportsDType[dtype[_SCT]],
]
_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
@@ -102,18 +98,18 @@ class _ndptr(ctypes.c_void_p, Generic[_DTypeOptional]):
_dtype_: ClassVar[_DTypeOptional]
_shape_: ClassVar[None]
_ndim_: ClassVar[None | int]
- _flags_: ClassVar[None | List[_FlagsKind]]
+ _flags_: ClassVar[None | list[_FlagsKind]]
@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: ...
@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: ...
class _concrete_ndptr(_ndptr[_DType]):
_dtype_: ClassVar[_DType]
- _shape_: ClassVar[Tuple[int, ...]]
+ _shape_: ClassVar[tuple[int, ...]]
@property
def contents(self) -> ndarray[Any, _DType]: ...
@@ -122,7 +118,7 @@ def load_library(
loader_path: str | bytes | os.PathLike[str] | os.PathLike[bytes],
) -> ctypes.CDLL: ...
-__all__: List[str]
+__all__: list[str]
c_intp = _c_intp
@@ -132,7 +128,7 @@ def ndpointer(
ndim: int = ...,
shape: None | _ShapeLike = ...,
flags: None | _FlagsKind | Iterable[_FlagsKind] | int | flagsobj = ...,
-) -> Type[_ndptr[None]]: ...
+) -> type[_ndptr[None]]: ...
@overload
def ndpointer(
dtype: _DTypeLike[_SCT],
@@ -140,7 +136,7 @@ def ndpointer(
*,
shape: _ShapeLike,
flags: None | _FlagsKind | Iterable[_FlagsKind] | int | flagsobj = ...,
-) -> Type[_concrete_ndptr[dtype[_SCT]]]: ...
+) -> type[_concrete_ndptr[dtype[_SCT]]]: ...
@overload
def ndpointer(
dtype: DTypeLike,
@@ -148,54 +144,54 @@ def ndpointer(
*,
shape: _ShapeLike,
flags: None | _FlagsKind | Iterable[_FlagsKind] | int | flagsobj = ...,
-) -> Type[_concrete_ndptr[dtype[Any]]]: ...
+) -> type[_concrete_ndptr[dtype[Any]]]: ...
@overload
def ndpointer(
dtype: _DTypeLike[_SCT],
ndim: int = ...,
shape: None = ...,
flags: None | _FlagsKind | Iterable[_FlagsKind] | int | flagsobj = ...,
-) -> Type[_ndptr[dtype[_SCT]]]: ...
+) -> type[_ndptr[dtype[_SCT]]]: ...
@overload
def ndpointer(
dtype: DTypeLike,
ndim: int = ...,
shape: None = ...,
flags: None | _FlagsKind | Iterable[_FlagsKind] | int | flagsobj = ...,
-) -> Type[_ndptr[dtype[Any]]]: ...
+) -> type[_ndptr[dtype[Any]]]: ...
@overload
-def as_ctypes_type(dtype: _BoolCodes | _DTypeLike[bool_] | Type[ctypes.c_bool]) -> Type[ctypes.c_bool]: ...
+def as_ctypes_type(dtype: _BoolCodes | _DTypeLike[bool_] | type[ctypes.c_bool]) -> type[ctypes.c_bool]: ...
@overload
-def as_ctypes_type(dtype: _ByteCodes | _DTypeLike[byte] | Type[ctypes.c_byte]) -> Type[ctypes.c_byte]: ...
+def as_ctypes_type(dtype: _ByteCodes | _DTypeLike[byte] | type[ctypes.c_byte]) -> type[ctypes.c_byte]: ...
@overload
-def as_ctypes_type(dtype: _ShortCodes | _DTypeLike[short] | Type[ctypes.c_short]) -> Type[ctypes.c_short]: ...
+def as_ctypes_type(dtype: _ShortCodes | _DTypeLike[short] | type[ctypes.c_short]) -> type[ctypes.c_short]: ...
@overload
-def as_ctypes_type(dtype: _IntCCodes | _DTypeLike[intc] | Type[ctypes.c_int]) -> Type[ctypes.c_int]: ...
+def as_ctypes_type(dtype: _IntCCodes | _DTypeLike[intc] | type[ctypes.c_int]) -> type[ctypes.c_int]: ...
@overload
-def as_ctypes_type(dtype: _IntCodes | _DTypeLike[int_] | Type[int | ctypes.c_long]) -> Type[ctypes.c_long]: ...
+def as_ctypes_type(dtype: _IntCodes | _DTypeLike[int_] | type[int | ctypes.c_long]) -> type[ctypes.c_long]: ...
@overload
-def as_ctypes_type(dtype: _LongLongCodes | _DTypeLike[longlong] | Type[ctypes.c_longlong]) -> Type[ctypes.c_longlong]: ...
+def as_ctypes_type(dtype: _LongLongCodes | _DTypeLike[longlong] | type[ctypes.c_longlong]) -> type[ctypes.c_longlong]: ...
@overload
-def as_ctypes_type(dtype: _UByteCodes | _DTypeLike[ubyte] | Type[ctypes.c_ubyte]) -> Type[ctypes.c_ubyte]: ...
+def as_ctypes_type(dtype: _UByteCodes | _DTypeLike[ubyte] | type[ctypes.c_ubyte]) -> type[ctypes.c_ubyte]: ...
@overload
-def as_ctypes_type(dtype: _UShortCodes | _DTypeLike[ushort] | Type[ctypes.c_ushort]) -> Type[ctypes.c_ushort]: ...
+def as_ctypes_type(dtype: _UShortCodes | _DTypeLike[ushort] | type[ctypes.c_ushort]) -> type[ctypes.c_ushort]: ...
@overload
-def as_ctypes_type(dtype: _UIntCCodes | _DTypeLike[uintc] | Type[ctypes.c_uint]) -> Type[ctypes.c_uint]: ...
+def as_ctypes_type(dtype: _UIntCCodes | _DTypeLike[uintc] | type[ctypes.c_uint]) -> type[ctypes.c_uint]: ...
@overload
-def as_ctypes_type(dtype: _UIntCodes | _DTypeLike[uint] | Type[ctypes.c_ulong]) -> Type[ctypes.c_ulong]: ...
+def as_ctypes_type(dtype: _UIntCodes | _DTypeLike[uint] | type[ctypes.c_ulong]) -> type[ctypes.c_ulong]: ...
@overload
-def as_ctypes_type(dtype: _ULongLongCodes | _DTypeLike[ulonglong] | Type[ctypes.c_ulonglong]) -> Type[ctypes.c_ulonglong]: ...
+def as_ctypes_type(dtype: _ULongLongCodes | _DTypeLike[ulonglong] | type[ctypes.c_ulonglong]) -> type[ctypes.c_ulonglong]: ...
@overload
-def as_ctypes_type(dtype: _SingleCodes | _DTypeLike[single] | Type[ctypes.c_float]) -> Type[ctypes.c_float]: ...
+def as_ctypes_type(dtype: _SingleCodes | _DTypeLike[single] | type[ctypes.c_float]) -> type[ctypes.c_float]: ...
@overload
-def as_ctypes_type(dtype: _DoubleCodes | _DTypeLike[double] | Type[float | ctypes.c_double]) -> Type[ctypes.c_double]: ...
+def as_ctypes_type(dtype: _DoubleCodes | _DTypeLike[double] | type[float | ctypes.c_double]) -> type[ctypes.c_double]: ...
@overload
-def as_ctypes_type(dtype: _LongDoubleCodes | _DTypeLike[longdouble] | Type[ctypes.c_longdouble]) -> Type[ctypes.c_longdouble]: ...
+def as_ctypes_type(dtype: _LongDoubleCodes | _DTypeLike[longdouble] | type[ctypes.c_longdouble]) -> type[ctypes.c_longdouble]: ...
@overload
-def as_ctypes_type(dtype: _VoidDTypeLike) -> Type[Any]: ... # `ctypes.Union` or `ctypes.Structure`
+def as_ctypes_type(dtype: _VoidDTypeLike) -> type[Any]: ... # `ctypes.Union` or `ctypes.Structure`
@overload
-def as_ctypes_type(dtype: str) -> Type[Any]: ...
+def as_ctypes_type(dtype: str) -> type[Any]: ...
@overload
def as_array(obj: ctypes._PointerLike, shape: Sequence[int]) -> NDArray[Any]: ...
diff --git a/numpy/f2py/__init__.pyi b/numpy/f2py/__init__.pyi
index e52e12bbd..af5a49328 100644
--- a/numpy/f2py/__init__.pyi
+++ b/numpy/f2py/__init__.pyi
@@ -1,28 +1,28 @@
import os
import subprocess
-from typing import Literal as L, Any, List, Iterable, Dict, overload, TypedDict
+from typing import Literal as L, Any, Iterable, overload, TypedDict
from numpy._pytesttester import PytestTester
class _F2PyDictBase(TypedDict):
- csrc: List[str]
- h: List[str]
+ csrc: list[str]
+ h: list[str]
class _F2PyDict(_F2PyDictBase, total=False):
- fsrc: List[str]
- ltx: List[str]
+ fsrc: list[str]
+ ltx: list[str]
-__all__: List[str]
-__path__: List[str]
+__all__: list[str]
+__path__: list[str]
test: PytestTester
-def run_main(comline_list: Iterable[str]) -> Dict[str, _F2PyDict]: ...
+def run_main(comline_list: Iterable[str]) -> dict[str, _F2PyDict]: ...
@overload
def compile( # type: ignore[misc]
source: str | bytes,
modulename: str = ...,
- extra_args: str | List[str] = ...,
+ extra_args: str | list[str] = ...,
verbose: bool = ...,
source_fn: None | str | bytes | os.PathLike[Any] = ...,
extension: L[".f", ".f90"] = ...,
@@ -32,7 +32,7 @@ def compile( # type: ignore[misc]
def compile(
source: str | bytes,
modulename: str = ...,
- extra_args: str | List[str] = ...,
+ extra_args: str | list[str] = ...,
verbose: bool = ...,
source_fn: None | str | bytes | os.PathLike[Any] = ...,
extension: L[".f", ".f90"] = ...,
diff --git a/numpy/fft/__init__.pyi b/numpy/fft/__init__.pyi
index 510e576d3..5518aac16 100644
--- a/numpy/fft/__init__.pyi
+++ b/numpy/fft/__init__.pyi
@@ -1,5 +1,3 @@
-from typing import Any, List
-
from numpy._pytesttester import PytestTester
from numpy.fft._pocketfft import (
@@ -26,6 +24,6 @@ from numpy.fft.helper import (
rfftfreq as rfftfreq,
)
-__all__: List[str]
-__path__: List[str]
+__all__: list[str]
+__path__: list[str]
test: PytestTester
diff --git a/numpy/fft/_pocketfft.pyi b/numpy/fft/_pocketfft.pyi
index 86cf6a60d..a04fff402 100644
--- a/numpy/fft/_pocketfft.pyi
+++ b/numpy/fft/_pocketfft.pyi
@@ -1,6 +1,5 @@
from typing import (
Literal as L,
- List,
Sequence,
)
@@ -9,7 +8,7 @@ from numpy.typing import ArrayLike, NDArray, _ArrayLikeNumber_co
_NormKind = L[None, "backward", "ortho", "forward"]
-__all__: List[str]
+__all__: list[str]
def fft(
a: ArrayLike,
diff --git a/numpy/fft/helper.pyi b/numpy/fft/helper.pyi
index d75826f4e..a7f3bdf51 100644
--- a/numpy/fft/helper.pyi
+++ b/numpy/fft/helper.pyi
@@ -1,4 +1,4 @@
-from typing import List, Any, TypeVar, overload
+from typing import Any, TypeVar, overload
from numpy import generic, dtype, integer, floating, complexfloating
from numpy.typing import (
@@ -15,7 +15,7 @@ _SCT = TypeVar("_SCT", bound=generic)
_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
-__all__: List[str]
+__all__: list[str]
@overload
def fftshift(x: _ArrayLike[_SCT], axes: None | _ShapeLike = ...) -> NDArray[_SCT]: ...
diff --git a/numpy/lib/__init__.pyi b/numpy/lib/__init__.pyi
index ae23b2ec4..7338fc6d6 100644
--- a/numpy/lib/__init__.pyi
+++ b/numpy/lib/__init__.pyi
@@ -1,5 +1,5 @@
import math as math
-from typing import Any, List
+from typing import Any
from numpy._pytesttester import PytestTester
@@ -237,8 +237,8 @@ from numpy.core.multiarray import (
tracemalloc_domain as tracemalloc_domain,
)
-__all__: List[str]
-__path__: List[str]
+__all__: list[str]
+__path__: list[str]
test: PytestTester
__version__ = version
diff --git a/numpy/lib/_version.pyi b/numpy/lib/_version.pyi
index e8b5026ca..1c82c99b6 100644
--- a/numpy/lib/_version.pyi
+++ b/numpy/lib/_version.pyi
@@ -1,6 +1,4 @@
-from typing import List
-
-__all__: List[str]
+__all__: list[str]
class NumpyVersion:
vstring: str
diff --git a/numpy/lib/arraypad.pyi b/numpy/lib/arraypad.pyi
index d7c5f4844..1f74f2506 100644
--- a/numpy/lib/arraypad.pyi
+++ b/numpy/lib/arraypad.pyi
@@ -1,10 +1,7 @@
from typing import (
Literal as L,
Any,
- Dict,
- List,
overload,
- Tuple,
TypeVar,
Protocol,
)
@@ -25,9 +22,9 @@ class _ModeFunc(Protocol):
def __call__(
self,
vector: NDArray[Any],
- iaxis_pad_width: Tuple[int, int],
+ iaxis_pad_width: tuple[int, int],
iaxis: int,
- kwargs: Dict[str, Any],
+ kwargs: dict[str, Any],
/,
) -> None: ...
@@ -47,7 +44,7 @@ _ModeKind = L[
_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
-__all__: List[str]
+__all__: list[str]
# TODO: In practice each keyword argument is exclusive to one or more
# specific modes. Consider adding more overloads to express this in the future.
diff --git a/numpy/lib/arraysetops.pyi b/numpy/lib/arraysetops.pyi
index 492affb10..e7e230bf1 100644
--- a/numpy/lib/arraysetops.pyi
+++ b/numpy/lib/arraysetops.pyi
@@ -1,9 +1,7 @@
from typing import (
Literal as L,
Any,
- List,
TypeVar,
- Tuple,
overload,
SupportsIndex,
)
@@ -91,7 +89,7 @@ _SCTNoCast = TypeVar(
_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
-__all__: List[str]
+__all__: list[str]
@overload
def ediff1d(
@@ -147,7 +145,7 @@ def unique(
return_inverse: L[False] = ...,
return_counts: L[False] = ...,
axis: None | SupportsIndex = ...,
-) -> Tuple[NDArray[_SCT], NDArray[intp]]: ...
+) -> tuple[NDArray[_SCT], NDArray[intp]]: ...
@overload
def unique(
ar: ArrayLike,
@@ -155,7 +153,7 @@ def unique(
return_inverse: L[False] = ...,
return_counts: L[False] = ...,
axis: None | SupportsIndex = ...,
-) -> Tuple[NDArray[Any], NDArray[intp]]: ...
+) -> tuple[NDArray[Any], NDArray[intp]]: ...
@overload
def unique(
ar: _ArrayLike[_SCT],
@@ -163,7 +161,7 @@ def unique(
return_inverse: L[True] = ...,
return_counts: L[False] = ...,
axis: None | SupportsIndex = ...,
-) -> Tuple[NDArray[_SCT], NDArray[intp]]: ...
+) -> tuple[NDArray[_SCT], NDArray[intp]]: ...
@overload
def unique(
ar: ArrayLike,
@@ -171,7 +169,7 @@ def unique(
return_inverse: L[True] = ...,
return_counts: L[False] = ...,
axis: None | SupportsIndex = ...,
-) -> Tuple[NDArray[Any], NDArray[intp]]: ...
+) -> tuple[NDArray[Any], NDArray[intp]]: ...
@overload
def unique(
ar: _ArrayLike[_SCT],
@@ -179,7 +177,7 @@ def unique(
return_inverse: L[False] = ...,
return_counts: L[True] = ...,
axis: None | SupportsIndex = ...,
-) -> Tuple[NDArray[_SCT], NDArray[intp]]: ...
+) -> tuple[NDArray[_SCT], NDArray[intp]]: ...
@overload
def unique(
ar: ArrayLike,
@@ -187,7 +185,7 @@ def unique(
return_inverse: L[False] = ...,
return_counts: L[True] = ...,
axis: None | SupportsIndex = ...,
-) -> Tuple[NDArray[Any], NDArray[intp]]: ...
+) -> tuple[NDArray[Any], NDArray[intp]]: ...
@overload
def unique(
ar: _ArrayLike[_SCT],
@@ -195,7 +193,7 @@ def unique(
return_inverse: L[True] = ...,
return_counts: L[False] = ...,
axis: None | SupportsIndex = ...,
-) -> Tuple[NDArray[_SCT], NDArray[intp], NDArray[intp]]: ...
+) -> tuple[NDArray[_SCT], NDArray[intp], NDArray[intp]]: ...
@overload
def unique(
ar: ArrayLike,
@@ -203,7 +201,7 @@ def unique(
return_inverse: L[True] = ...,
return_counts: L[False] = ...,
axis: None | SupportsIndex = ...,
-) -> Tuple[NDArray[Any], NDArray[intp], NDArray[intp]]: ...
+) -> tuple[NDArray[Any], NDArray[intp], NDArray[intp]]: ...
@overload
def unique(
ar: _ArrayLike[_SCT],
@@ -211,7 +209,7 @@ def unique(
return_inverse: L[False] = ...,
return_counts: L[True] = ...,
axis: None | SupportsIndex = ...,
-) -> Tuple[NDArray[_SCT], NDArray[intp], NDArray[intp]]: ...
+) -> tuple[NDArray[_SCT], NDArray[intp], NDArray[intp]]: ...
@overload
def unique(
ar: ArrayLike,
@@ -219,7 +217,7 @@ def unique(
return_inverse: L[False] = ...,
return_counts: L[True] = ...,
axis: None | SupportsIndex = ...,
-) -> Tuple[NDArray[Any], NDArray[intp], NDArray[intp]]: ...
+) -> tuple[NDArray[Any], NDArray[intp], NDArray[intp]]: ...
@overload
def unique(
ar: _ArrayLike[_SCT],
@@ -227,7 +225,7 @@ def unique(
return_inverse: L[True] = ...,
return_counts: L[True] = ...,
axis: None | SupportsIndex = ...,
-) -> Tuple[NDArray[_SCT], NDArray[intp], NDArray[intp]]: ...
+) -> tuple[NDArray[_SCT], NDArray[intp], NDArray[intp]]: ...
@overload
def unique(
ar: ArrayLike,
@@ -235,7 +233,7 @@ def unique(
return_inverse: L[True] = ...,
return_counts: L[True] = ...,
axis: None | SupportsIndex = ...,
-) -> Tuple[NDArray[Any], NDArray[intp], NDArray[intp]]: ...
+) -> tuple[NDArray[Any], NDArray[intp], NDArray[intp]]: ...
@overload
def unique(
ar: _ArrayLike[_SCT],
@@ -243,7 +241,7 @@ def unique(
return_inverse: L[True] = ...,
return_counts: L[True] = ...,
axis: None | SupportsIndex = ...,
-) -> Tuple[NDArray[_SCT], NDArray[intp], NDArray[intp], NDArray[intp]]: ...
+) -> tuple[NDArray[_SCT], NDArray[intp], NDArray[intp], NDArray[intp]]: ...
@overload
def unique(
ar: ArrayLike,
@@ -251,7 +249,7 @@ def unique(
return_inverse: L[True] = ...,
return_counts: L[True] = ...,
axis: None | SupportsIndex = ...,
-) -> Tuple[NDArray[Any], NDArray[intp], NDArray[intp], NDArray[intp]]: ...
+) -> tuple[NDArray[Any], NDArray[intp], NDArray[intp], NDArray[intp]]: ...
@overload
def intersect1d(
@@ -273,14 +271,14 @@ def intersect1d(
ar2: _ArrayLike[_SCTNoCast],
assume_unique: bool = ...,
return_indices: L[True] = ...,
-) -> Tuple[NDArray[_SCTNoCast], NDArray[intp], NDArray[intp]]: ...
+) -> tuple[NDArray[_SCTNoCast], NDArray[intp], NDArray[intp]]: ...
@overload
def intersect1d(
ar1: ArrayLike,
ar2: ArrayLike,
assume_unique: bool = ...,
return_indices: L[True] = ...,
-) -> Tuple[NDArray[Any], NDArray[intp], NDArray[intp]]: ...
+) -> tuple[NDArray[Any], NDArray[intp], NDArray[intp]]: ...
@overload
def setxor1d(
diff --git a/numpy/lib/arrayterator.pyi b/numpy/lib/arrayterator.pyi
index 82c669206..71fc1b6d7 100644
--- a/numpy/lib/arrayterator.pyi
+++ b/numpy/lib/arrayterator.pyi
@@ -1,11 +1,8 @@
from typing import (
- List,
Any,
TypeVar,
Generator,
- List,
Union,
- Tuple,
overload,
)
@@ -19,10 +16,10 @@ _ScalarType = TypeVar("_ScalarType", bound=generic)
_Index = Union[
Union[ellipsis, int, slice],
- Tuple[Union[ellipsis, int, slice], ...],
+ tuple[Union[ellipsis, int, slice], ...],
]
-__all__: List[str]
+__all__: list[str]
# NOTE: In reality `Arrayterator` does not actually inherit from `ndarray`,
# but its ``__getattr__` method does wrap around the former and thus has
@@ -31,12 +28,12 @@ __all__: List[str]
class Arrayterator(ndarray[_Shape, _DType]):
var: ndarray[_Shape, _DType] # type: ignore[assignment]
buf_size: None | int
- start: List[int]
- stop: List[int]
- step: List[int]
+ start: list[int]
+ stop: list[int]
+ step: list[int]
@property # type: ignore[misc]
- def shape(self) -> Tuple[int, ...]: ...
+ def shape(self) -> tuple[int, ...]: ...
@property
def flat( # type: ignore[override]
self: ndarray[Any, dtype[_ScalarType]]
diff --git a/numpy/lib/format.pyi b/numpy/lib/format.pyi
index 092245daf..a4468f52f 100644
--- a/numpy/lib/format.pyi
+++ b/numpy/lib/format.pyi
@@ -1,8 +1,8 @@
-from typing import Any, List, Set, Literal, Final
+from typing import Any, Literal, Final
-__all__: List[str]
+__all__: list[str]
-EXPECTED_KEYS: Final[Set[str]]
+EXPECTED_KEYS: Final[set[str]]
MAGIC_PREFIX: Final[bytes]
MAGIC_LEN: Literal[8]
ARRAY_ALIGN: Literal[64]
diff --git a/numpy/lib/function_base.pyi b/numpy/lib/function_base.pyi
index 7e227f9da..157ee783d 100644
--- a/numpy/lib/function_base.pyi
+++ b/numpy/lib/function_base.pyi
@@ -1,10 +1,7 @@
import sys
from typing import (
Literal as L,
- List,
- Type,
Sequence,
- Tuple,
Union,
Any,
TypeVar,
@@ -73,11 +70,11 @@ _T_co = TypeVar("_T_co", covariant=True)
_SCT = TypeVar("_SCT", bound=generic)
_ArrayType = TypeVar("_ArrayType", bound=NDArray[Any])
-_2Tuple = Tuple[_T, _T]
+_2Tuple = tuple[_T, _T]
_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
_DTypeLike = Union[
dtype[_SCT],
- Type[_SCT],
+ type[_SCT],
_SupportsDType[dtype[_SCT]],
]
@@ -90,7 +87,7 @@ class _SupportsWriteFlush(Protocol):
def write(self, s: str, /) -> object: ...
def flush(self) -> object: ...
-__all__: List[str]
+__all__: list[str]
# NOTE: This is in reality a re-export of `np.core.umath._add_newdoc_ufunc`
def add_newdoc_ufunc(ufunc: ufunc, new_docstring: str, /) -> None: ...
@@ -99,13 +96,13 @@ def add_newdoc_ufunc(ufunc: ufunc, new_docstring: str, /) -> None: ...
def rot90(
m: _ArrayLike[_SCT],
k: int = ...,
- axes: Tuple[int, int] = ...,
+ axes: tuple[int, int] = ...,
) -> NDArray[_SCT]: ...
@overload
def rot90(
m: ArrayLike,
k: int = ...,
- axes: Tuple[int, int] = ...,
+ axes: tuple[int, int] = ...,
) -> NDArray[Any]: ...
@overload
@@ -654,7 +651,7 @@ def meshgrid(
copy: bool = ...,
sparse: bool = ...,
indexing: L["xy", "ij"] = ...,
-) -> List[NDArray[Any]]: ...
+) -> list[NDArray[Any]]: ...
@overload
def delete(
diff --git a/numpy/lib/histograms.pyi b/numpy/lib/histograms.pyi
index 2ceb60793..a809bc905 100644
--- a/numpy/lib/histograms.pyi
+++ b/numpy/lib/histograms.pyi
@@ -1,7 +1,5 @@
from typing import (
Literal as L,
- List,
- Tuple,
Any,
SupportsIndex,
Sequence,
@@ -23,29 +21,29 @@ _BinKind = L[
"sturges",
]
-__all__: List[str]
+__all__: list[str]
def histogram_bin_edges(
a: ArrayLike,
bins: _BinKind | SupportsIndex | ArrayLike = ...,
- range: None | Tuple[float, float] = ...,
+ range: None | tuple[float, float] = ...,
weights: None | ArrayLike = ...,
) -> NDArray[Any]: ...
def histogram(
a: ArrayLike,
bins: _BinKind | SupportsIndex | ArrayLike = ...,
- range: None | Tuple[float, float] = ...,
+ range: None | tuple[float, float] = ...,
normed: None = ...,
weights: None | ArrayLike = ...,
density: bool = ...,
-) -> Tuple[NDArray[Any], NDArray[Any]]: ...
+) -> tuple[NDArray[Any], NDArray[Any]]: ...
def histogramdd(
sample: ArrayLike,
bins: SupportsIndex | ArrayLike = ...,
- range: Sequence[Tuple[float, float]] = ...,
+ range: Sequence[tuple[float, float]] = ...,
normed: None | bool = ...,
weights: None | ArrayLike = ...,
density: None | bool = ...,
-) -> Tuple[NDArray[Any], List[NDArray[Any]]]: ...
+) -> tuple[NDArray[Any], list[NDArray[Any]]]: ...
diff --git a/numpy/lib/index_tricks.pyi b/numpy/lib/index_tricks.pyi
index 6aa8b2571..1e6aa6968 100644
--- a/numpy/lib/index_tricks.pyi
+++ b/numpy/lib/index_tricks.pyi
@@ -1,10 +1,8 @@
from typing import (
Any,
- Tuple,
TypeVar,
Generic,
overload,
- List,
Sequence,
Literal,
SupportsIndex,
@@ -52,25 +50,25 @@ from numpy.core.multiarray import (
_T = TypeVar("_T")
_DType = TypeVar("_DType", bound=dtype[Any])
_BoolType = TypeVar("_BoolType", Literal[True], Literal[False])
-_TupType = TypeVar("_TupType", bound=Tuple[Any, ...])
+_TupType = TypeVar("_TupType", bound=tuple[Any, ...])
_ArrayType = TypeVar("_ArrayType", bound=ndarray[Any, Any])
-__all__: List[str]
+__all__: list[str]
@overload
-def ix_(*args: _FiniteNestedSequence[_SupportsDType[_DType]]) -> Tuple[ndarray[Any, _DType], ...]: ...
+def ix_(*args: _FiniteNestedSequence[_SupportsDType[_DType]]) -> tuple[ndarray[Any, _DType], ...]: ...
@overload
-def ix_(*args: str | _NestedSequence[str]) -> Tuple[NDArray[str_], ...]: ...
+def ix_(*args: str | _NestedSequence[str]) -> tuple[NDArray[str_], ...]: ...
@overload
-def ix_(*args: bytes | _NestedSequence[bytes]) -> Tuple[NDArray[bytes_], ...]: ...
+def ix_(*args: bytes | _NestedSequence[bytes]) -> tuple[NDArray[bytes_], ...]: ...
@overload
-def ix_(*args: bool | _NestedSequence[bool]) -> Tuple[NDArray[bool_], ...]: ...
+def ix_(*args: bool | _NestedSequence[bool]) -> tuple[NDArray[bool_], ...]: ...
@overload
-def ix_(*args: int | _NestedSequence[int]) -> Tuple[NDArray[int_], ...]: ...
+def ix_(*args: int | _NestedSequence[int]) -> tuple[NDArray[int_], ...]: ...
@overload
-def ix_(*args: float | _NestedSequence[float]) -> Tuple[NDArray[float_], ...]: ...
+def ix_(*args: float | _NestedSequence[float]) -> tuple[NDArray[float_], ...]: ...
@overload
-def ix_(*args: complex | _NestedSequence[complex]) -> Tuple[NDArray[complex_], ...]: ...
+def ix_(*args: complex | _NestedSequence[complex]) -> tuple[NDArray[complex_], ...]: ...
class nd_grid(Generic[_BoolType]):
sparse: _BoolType
@@ -84,7 +82,7 @@ class nd_grid(Generic[_BoolType]):
def __getitem__(
self: nd_grid[Literal[True]],
key: slice | Sequence[slice],
- ) -> List[NDArray[Any]]: ...
+ ) -> list[NDArray[Any]]: ...
class MGridClass(nd_grid[Literal[False]]):
def __init__(self) -> None: ...
@@ -150,7 +148,7 @@ class IndexExpression(Generic[_BoolType]):
@overload
def __getitem__(self, item: _TupType) -> _TupType: ... # type: ignore[misc]
@overload
- def __getitem__(self: IndexExpression[Literal[True]], item: _T) -> Tuple[_T]: ...
+ def __getitem__(self: IndexExpression[Literal[True]], item: _T) -> tuple[_T]: ...
@overload
def __getitem__(self: IndexExpression[Literal[False]], item: _T) -> _T: ...
@@ -158,7 +156,7 @@ index_exp: IndexExpression[Literal[True]]
s_: IndexExpression[Literal[False]]
def fill_diagonal(a: ndarray[Any, Any], val: Any, wrap: bool = ...) -> None: ...
-def diag_indices(n: int, ndim: int = ...) -> Tuple[NDArray[int_], ...]: ...
-def diag_indices_from(arr: ArrayLike) -> Tuple[NDArray[int_], ...]: ...
+def diag_indices(n: int, ndim: int = ...) -> tuple[NDArray[int_], ...]: ...
+def diag_indices_from(arr: ArrayLike) -> tuple[NDArray[int_], ...]: ...
# NOTE: see `numpy/__init__.pyi` for `ndenumerate` and `ndindex`
diff --git a/numpy/lib/mixins.pyi b/numpy/lib/mixins.pyi
index f137bb5bc..d52c8fa0b 100644
--- a/numpy/lib/mixins.pyi
+++ b/numpy/lib/mixins.pyi
@@ -1,7 +1,6 @@
-from typing import List
from abc import ABCMeta, abstractmethod
-__all__: List[str]
+__all__: list[str]
# NOTE: `NDArrayOperatorsMixin` is not formally an abstract baseclass,
# even though it's reliant on subclasses implementing `__array_ufunc__`
diff --git a/numpy/lib/nanfunctions.pyi b/numpy/lib/nanfunctions.pyi
index 54b4a7e26..8642055fe 100644
--- a/numpy/lib/nanfunctions.pyi
+++ b/numpy/lib/nanfunctions.pyi
@@ -1,5 +1,3 @@
-from typing import List
-
from numpy.core.fromnumeric import (
amin,
amax,
@@ -20,7 +18,7 @@ from numpy.lib.function_base import (
quantile,
)
-__all__: List[str]
+__all__: list[str]
# NOTE: In reaility these functions are not aliases but distinct functions
# with identical signatures.
diff --git a/numpy/lib/npyio.pyi b/numpy/lib/npyio.pyi
index 04e0494ae..326358c13 100644
--- a/numpy/lib/npyio.pyi
+++ b/numpy/lib/npyio.pyi
@@ -9,8 +9,6 @@ from typing import (
Mapping,
TypeVar,
Generic,
- List,
- Type,
Iterator,
Union,
IO,
@@ -49,7 +47,7 @@ _CharType_co = TypeVar("_CharType_co", str, bytes, covariant=True)
_CharType_contra = TypeVar("_CharType_contra", str, bytes, contravariant=True)
_DTypeLike = Union[
- Type[_SCT],
+ type[_SCT],
dtype[_SCT],
_SupportsDType[dtype[_SCT]],
]
@@ -67,17 +65,17 @@ class _SupportsReadSeek(Protocol[_CharType_co]):
class _SupportsWrite(Protocol[_CharType_contra]):
def write(self, s: _CharType_contra, /) -> object: ...
-__all__: List[str]
+__all__: list[str]
class BagObj(Generic[_T_co]):
def __init__(self, obj: _SupportsGetItem[str, _T_co]) -> None: ...
def __getattribute__(self, key: str) -> _T_co: ...
- def __dir__(self) -> List[str]: ...
+ def __dir__(self) -> list[str]: ...
class NpzFile(Mapping[str, NDArray[Any]]):
zip: zipfile.ZipFile
fid: None | IO[str]
- files: List[str]
+ files: list[str]
allow_pickle: bool
pickle_kwargs: None | Mapping[str, Any]
# Represent `f` as a mutable property so we can access the type of `self`
@@ -95,7 +93,7 @@ class NpzFile(Mapping[str, NDArray[Any]]):
def __enter__(self: _T) -> _T: ...
def __exit__(
self,
- exc_type: None | Type[BaseException],
+ exc_type: None | type[BaseException],
exc_value: None | BaseException,
traceback: None | types.TracebackType,
/,
diff --git a/numpy/lib/polynomial.pyi b/numpy/lib/polynomial.pyi
index 00065f53b..7ba4747bd 100644
--- a/numpy/lib/polynomial.pyi
+++ b/numpy/lib/polynomial.pyi
@@ -1,12 +1,10 @@
from typing import (
Literal as L,
- List,
overload,
Any,
SupportsInt,
SupportsIndex,
TypeVar,
- Tuple,
NoReturn,
)
@@ -38,8 +36,8 @@ from numpy.typing import (
_T = TypeVar("_T")
-_2Tup = Tuple[_T, _T]
-_5Tup = Tuple[
+_2Tup = tuple[_T, _T]
+_5Tup = tuple[
_T,
NDArray[float64],
NDArray[int32],
@@ -47,7 +45,7 @@ _5Tup = Tuple[
NDArray[float64],
]
-__all__: List[str]
+__all__: list[str]
def poly(seq_of_zeros: ArrayLike) -> NDArray[floating[Any]]: ...
diff --git a/numpy/lib/scimath.pyi b/numpy/lib/scimath.pyi
index 6f196497d..1b13a6805 100644
--- a/numpy/lib/scimath.pyi
+++ b/numpy/lib/scimath.pyi
@@ -1,4 +1,4 @@
-from typing import List, overload, Any
+from typing import overload, Any
from numpy import complexfloating
@@ -10,7 +10,7 @@ from numpy.typing import (
_FloatLike_co,
)
-__all__: List[str]
+__all__: list[str]
@overload
def sqrt(x: _FloatLike_co) -> Any: ...
diff --git a/numpy/lib/shape_base.pyi b/numpy/lib/shape_base.pyi
index 17016c999..b659481ce 100644
--- a/numpy/lib/shape_base.pyi
+++ b/numpy/lib/shape_base.pyi
@@ -1,4 +1,4 @@
-from typing import List, TypeVar, Callable, Sequence, Any, overload, Tuple, SupportsIndex, Protocol
+from typing import TypeVar, Callable, Sequence, Any, overload, SupportsIndex, Protocol
from numpy import (
generic,
@@ -39,7 +39,7 @@ class _ArrayWrap(Protocol):
def __call__(
self,
array: NDArray[Any],
- context: None | Tuple[ufunc, Tuple[Any, ...], int] = ...,
+ context: None | tuple[ufunc, tuple[Any, ...], int] = ...,
/,
) -> Any: ...
@@ -47,7 +47,7 @@ class _ArrayPrepare(Protocol):
def __call__(
self,
array: NDArray[Any],
- context: None | Tuple[ufunc, Tuple[Any, ...], int] = ...,
+ context: None | tuple[ufunc, tuple[Any, ...], int] = ...,
/,
) -> Any: ...
@@ -59,7 +59,7 @@ class _SupportsArrayPrepare(Protocol):
@property
def __array_prepare__(self) -> _ArrayPrepare: ...
-__all__: List[str]
+__all__: list[str]
row_stack = vstack
@@ -125,59 +125,59 @@ def array_split(
ary: _ArrayLike[_SCT],
indices_or_sections: _ShapeLike,
axis: SupportsIndex = ...,
-) -> List[NDArray[_SCT]]: ...
+) -> list[NDArray[_SCT]]: ...
@overload
def array_split(
ary: ArrayLike,
indices_or_sections: _ShapeLike,
axis: SupportsIndex = ...,
-) -> List[NDArray[Any]]: ...
+) -> list[NDArray[Any]]: ...
@overload
def split(
ary: _ArrayLike[_SCT],
indices_or_sections: _ShapeLike,
axis: SupportsIndex = ...,
-) -> List[NDArray[_SCT]]: ...
+) -> list[NDArray[_SCT]]: ...
@overload
def split(
ary: ArrayLike,
indices_or_sections: _ShapeLike,
axis: SupportsIndex = ...,
-) -> List[NDArray[Any]]: ...
+) -> list[NDArray[Any]]: ...
@overload
def hsplit(
ary: _ArrayLike[_SCT],
indices_or_sections: _ShapeLike,
-) -> List[NDArray[_SCT]]: ...
+) -> list[NDArray[_SCT]]: ...
@overload
def hsplit(
ary: ArrayLike,
indices_or_sections: _ShapeLike,
-) -> List[NDArray[Any]]: ...
+) -> list[NDArray[Any]]: ...
@overload
def vsplit(
ary: _ArrayLike[_SCT],
indices_or_sections: _ShapeLike,
-) -> List[NDArray[_SCT]]: ...
+) -> list[NDArray[_SCT]]: ...
@overload
def vsplit(
ary: ArrayLike,
indices_or_sections: _ShapeLike,
-) -> List[NDArray[Any]]: ...
+) -> list[NDArray[Any]]: ...
@overload
def dsplit(
ary: _ArrayLike[_SCT],
indices_or_sections: _ShapeLike,
-) -> List[NDArray[_SCT]]: ...
+) -> list[NDArray[_SCT]]: ...
@overload
def dsplit(
ary: ArrayLike,
indices_or_sections: _ShapeLike,
-) -> List[NDArray[Any]]: ...
+) -> list[NDArray[Any]]: ...
@overload
def get_array_prepare(*args: _SupportsArrayPrepare) -> _ArrayPrepare: ...
diff --git a/numpy/lib/stride_tricks.pyi b/numpy/lib/stride_tricks.pyi
index aad404107..5f6e30726 100644
--- a/numpy/lib/stride_tricks.pyi
+++ b/numpy/lib/stride_tricks.pyi
@@ -1,4 +1,4 @@
-from typing import Any, List, Dict, Iterable, TypeVar, overload, SupportsIndex
+from typing import Any, Iterable, TypeVar, overload, SupportsIndex
from numpy import dtype, generic
from numpy.typing import (
@@ -13,14 +13,14 @@ from numpy.typing import (
_SCT = TypeVar("_SCT", bound=generic)
_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
-__all__: List[str]
+__all__: list[str]
class DummyArray:
- __array_interface__: Dict[str, Any]
+ __array_interface__: dict[str, Any]
base: None | NDArray[Any]
def __init__(
self,
- interface: Dict[str, Any],
+ interface: dict[str, Any],
base: None | NDArray[Any] = ...,
) -> None: ...
@@ -78,4 +78,4 @@ def broadcast_shapes(*args: _ShapeLike) -> _Shape: ...
def broadcast_arrays(
*args: ArrayLike,
subok: bool = ...,
-) -> List[NDArray[Any]]: ...
+) -> list[NDArray[Any]]: ...
diff --git a/numpy/lib/twodim_base.pyi b/numpy/lib/twodim_base.pyi
index cba503ca3..626682bdb 100644
--- a/numpy/lib/twodim_base.pyi
+++ b/numpy/lib/twodim_base.pyi
@@ -1,11 +1,8 @@
from typing import (
Any,
Callable,
- List,
Sequence,
overload,
- Tuple,
- Type,
TypeVar,
Union,
)
@@ -51,13 +48,13 @@ _MaskFunc = Callable[
]
_DTypeLike = Union[
- Type[_SCT],
+ type[_SCT],
dtype[_SCT],
_SupportsDType[dtype[_SCT]],
]
_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
-__all__: List[str]
+__all__: list[str]
@overload
def fliplr(m: _ArrayLike[_SCT]) -> NDArray[_SCT]: ...
@@ -182,7 +179,7 @@ def histogram2d( # type: ignore[misc]
normed: None | bool = ...,
weights: None | _ArrayLikeFloat_co = ...,
density: None | bool = ...,
-) -> Tuple[
+) -> tuple[
NDArray[float64],
NDArray[floating[Any]],
NDArray[floating[Any]],
@@ -196,7 +193,7 @@ def histogram2d(
normed: None | bool = ...,
weights: None | _ArrayLikeFloat_co = ...,
density: None | bool = ...,
-) -> Tuple[
+) -> tuple[
NDArray[float64],
NDArray[complexfloating[Any, Any]],
NDArray[complexfloating[Any, Any]],
@@ -210,7 +207,7 @@ def histogram2d(
normed: None | bool = ...,
weights: None | _ArrayLikeFloat_co = ...,
density: None | bool = ...,
-) -> Tuple[
+) -> tuple[
NDArray[float64],
NDArray[Any],
NDArray[Any],
@@ -224,32 +221,32 @@ def mask_indices(
n: int,
mask_func: _MaskFunc[int],
k: int = ...,
-) -> Tuple[NDArray[intp], NDArray[intp]]: ...
+) -> tuple[NDArray[intp], NDArray[intp]]: ...
@overload
def mask_indices(
n: int,
mask_func: _MaskFunc[_T],
k: _T,
-) -> Tuple[NDArray[intp], NDArray[intp]]: ...
+) -> tuple[NDArray[intp], NDArray[intp]]: ...
def tril_indices(
n: int,
k: int = ...,
m: None | int = ...,
-) -> Tuple[NDArray[int_], NDArray[int_]]: ...
+) -> tuple[NDArray[int_], NDArray[int_]]: ...
def tril_indices_from(
arr: NDArray[Any],
k: int = ...,
-) -> Tuple[NDArray[int_], NDArray[int_]]: ...
+) -> tuple[NDArray[int_], NDArray[int_]]: ...
def triu_indices(
n: int,
k: int = ...,
m: None | int = ...,
-) -> Tuple[NDArray[int_], NDArray[int_]]: ...
+) -> tuple[NDArray[int_], NDArray[int_]]: ...
def triu_indices_from(
arr: NDArray[Any],
k: int = ...,
-) -> Tuple[NDArray[int_], NDArray[int_]]: ...
+) -> tuple[NDArray[int_], NDArray[int_]]: ...
diff --git a/numpy/lib/type_check.pyi b/numpy/lib/type_check.pyi
index 510f36cd7..5fba3a7f5 100644
--- a/numpy/lib/type_check.pyi
+++ b/numpy/lib/type_check.pyi
@@ -3,9 +3,7 @@ from typing import (
Any,
Container,
Iterable,
- List,
overload,
- Type,
TypeVar,
Protocol,
)
@@ -49,7 +47,7 @@ class _SupportsImag(Protocol[_T_co]):
@property
def imag(self) -> _T_co: ...
-__all__: List[str]
+__all__: list[str]
def mintypecode(
typechars: Iterable[str | ArrayLike],
@@ -62,7 +60,7 @@ def mintypecode(
@overload
def asfarray(
a: object,
- dtype: None | Type[float] = ...,
+ dtype: None | type[float] = ...,
) -> NDArray[float64]: ...
@overload
def asfarray( # type: ignore[misc]
@@ -201,28 +199,28 @@ def common_type( # type: ignore[misc]
*arrays: _SupportsDType[dtype[
integer[Any]
]]
-) -> Type[floating[_64Bit]]: ...
+) -> type[floating[_64Bit]]: ...
@overload
def common_type( # type: ignore[misc]
*arrays: _SupportsDType[dtype[
floating[_NBit1]
]]
-) -> Type[floating[_NBit1]]: ...
+) -> type[floating[_NBit1]]: ...
@overload
def common_type( # type: ignore[misc]
*arrays: _SupportsDType[dtype[
integer[Any] | floating[_NBit1]
]]
-) -> Type[floating[_NBit1 | _64Bit]]: ...
+) -> type[floating[_NBit1 | _64Bit]]: ...
@overload
def common_type( # type: ignore[misc]
*arrays: _SupportsDType[dtype[
floating[_NBit1] | complexfloating[_NBit2, _NBit2]
]]
-) -> Type[complexfloating[_NBit1 | _NBit2, _NBit1 | _NBit2]]: ...
+) -> type[complexfloating[_NBit1 | _NBit2, _NBit1 | _NBit2]]: ...
@overload
def common_type(
*arrays: _SupportsDType[dtype[
integer[Any] | floating[_NBit1] | complexfloating[_NBit2, _NBit2]
]]
-) -> Type[complexfloating[_64Bit | _NBit1 | _NBit2, _64Bit | _NBit1 | _NBit2]]: ...
+) -> type[complexfloating[_64Bit | _NBit1 | _NBit2, _64Bit | _NBit1 | _NBit2]]: ...
diff --git a/numpy/lib/ufunclike.pyi b/numpy/lib/ufunclike.pyi
index bd48816e5..9a6bbc825 100644
--- a/numpy/lib/ufunclike.pyi
+++ b/numpy/lib/ufunclike.pyi
@@ -1,4 +1,4 @@
-from typing import Any, overload, TypeVar, List
+from typing import Any, overload, TypeVar
from numpy import floating, bool_, object_, ndarray
from numpy.typing import (
@@ -10,7 +10,7 @@ from numpy.typing import (
_ArrayType = TypeVar("_ArrayType", bound=ndarray[Any, Any])
-__all__: List[str]
+__all__: list[str]
@overload
def fix( # type: ignore[misc]
diff --git a/numpy/lib/utils.pyi b/numpy/lib/utils.pyi
index ef4f8cd4a..5bde8e620 100644
--- a/numpy/lib/utils.pyi
+++ b/numpy/lib/utils.pyi
@@ -2,11 +2,9 @@ from ast import AST
from typing import (
Any,
Callable,
- List,
Mapping,
overload,
Sequence,
- Tuple,
TypeVar,
Protocol,
)
@@ -26,7 +24,7 @@ _FuncType = TypeVar("_FuncType", bound=Callable[..., Any])
class _SupportsWrite(Protocol[_T_contra]):
def write(self, s: _T_contra, /) -> Any: ...
-__all__: List[str]
+__all__: list[str]
class _Deprecate:
old_name: None | str
@@ -66,7 +64,7 @@ def deprecate_with_doc(msg: None | str) -> _Deprecate: ...
# implementing the `__array_interface__` protocol. The caveat is
# that certain keys, marked as optional in the spec, must be present for
# `byte_bounds`. This concerns `"strides"` and `"data"`.
-def byte_bounds(a: generic | ndarray[Any, Any]) -> Tuple[int, int]: ...
+def byte_bounds(a: generic | ndarray[Any, Any]) -> tuple[int, int]: ...
def who(vardict: None | Mapping[str, ndarray[Any, Any]] = ...) -> None: ...
diff --git a/numpy/linalg/__init__.pyi b/numpy/linalg/__init__.pyi
index d457f153a..eef773af2 100644
--- a/numpy/linalg/__init__.pyi
+++ b/numpy/linalg/__init__.pyi
@@ -1,4 +1,4 @@
-from typing import Any, List
+from typing import Any
from numpy.linalg.linalg import (
matrix_power as matrix_power,
@@ -25,8 +25,8 @@ from numpy.linalg.linalg import (
from numpy._pytesttester import PytestTester
-__all__: List[str]
-__path__: List[str]
+__all__: list[str]
+__path__: list[str]
test: PytestTester
class LinAlgError(Exception): ...
diff --git a/numpy/linalg/linalg.pyi b/numpy/linalg/linalg.pyi
index a60b9539e..ca7958e61 100644
--- a/numpy/linalg/linalg.pyi
+++ b/numpy/linalg/linalg.pyi
@@ -1,13 +1,11 @@
from typing import (
Literal as L,
- List,
Iterable,
overload,
TypeVar,
Any,
SupportsIndex,
SupportsInt,
- Tuple,
)
from numpy import (
@@ -34,10 +32,10 @@ from numpy.typing import (
_T = TypeVar("_T")
_ArrayType = TypeVar("_ArrayType", bound=NDArray[Any])
-_2Tuple = Tuple[_T, _T]
+_2Tuple = tuple[_T, _T]
_ModeKind = L["reduced", "complete", "r", "raw"]
-__all__: List[str]
+__all__: list[str]
@overload
def tensorsolve(
@@ -141,17 +139,17 @@ def eig(a: _ArrayLikeComplex_co) -> _2Tuple[NDArray[complexfloating[Any, Any]]]:
def eigh(
a: _ArrayLikeInt_co,
UPLO: L["L", "U", "l", "u"] = ...,
-) -> Tuple[NDArray[float64], NDArray[float64]]: ...
+) -> tuple[NDArray[float64], NDArray[float64]]: ...
@overload
def eigh(
a: _ArrayLikeFloat_co,
UPLO: L["L", "U", "l", "u"] = ...,
-) -> Tuple[NDArray[floating[Any]], NDArray[floating[Any]]]: ...
+) -> tuple[NDArray[floating[Any]], NDArray[floating[Any]]]: ...
@overload
def eigh(
a: _ArrayLikeComplex_co,
UPLO: L["L", "U", "l", "u"] = ...,
-) -> Tuple[NDArray[floating[Any]], NDArray[complexfloating[Any, Any]]]: ...
+) -> tuple[NDArray[floating[Any]], NDArray[complexfloating[Any, Any]]]: ...
@overload
def svd(
@@ -159,7 +157,7 @@ def svd(
full_matrices: bool = ...,
compute_uv: L[True] = ...,
hermitian: bool = ...,
-) -> Tuple[
+) -> tuple[
NDArray[float64],
NDArray[float64],
NDArray[float64],
@@ -170,7 +168,7 @@ def svd(
full_matrices: bool = ...,
compute_uv: L[True] = ...,
hermitian: bool = ...,
-) -> Tuple[
+) -> tuple[
NDArray[floating[Any]],
NDArray[floating[Any]],
NDArray[floating[Any]],
@@ -181,7 +179,7 @@ def svd(
full_matrices: bool = ...,
compute_uv: L[True] = ...,
hermitian: bool = ...,
-) -> Tuple[
+) -> tuple[
NDArray[complexfloating[Any, Any]],
NDArray[floating[Any]],
NDArray[complexfloating[Any, Any]],
@@ -240,21 +238,21 @@ def slogdet(a: _ArrayLikeComplex_co) -> _2Tuple[Any]: ...
def det(a: _ArrayLikeComplex_co) -> Any: ...
@overload
-def lstsq(a: _ArrayLikeInt_co, b: _ArrayLikeInt_co, rcond: None | float = ...) -> Tuple[
+def lstsq(a: _ArrayLikeInt_co, b: _ArrayLikeInt_co, rcond: None | float = ...) -> tuple[
NDArray[float64],
NDArray[float64],
int32,
NDArray[float64],
]: ...
@overload
-def lstsq(a: _ArrayLikeFloat_co, b: _ArrayLikeFloat_co, rcond: None | float = ...) -> Tuple[
+def lstsq(a: _ArrayLikeFloat_co, b: _ArrayLikeFloat_co, rcond: None | float = ...) -> tuple[
NDArray[floating[Any]],
NDArray[floating[Any]],
int32,
NDArray[floating[Any]],
]: ...
@overload
-def lstsq(a: _ArrayLikeComplex_co, b: _ArrayLikeComplex_co, rcond: None | float = ...) -> Tuple[
+def lstsq(a: _ArrayLikeComplex_co, b: _ArrayLikeComplex_co, rcond: None | float = ...) -> tuple[
NDArray[complexfloating[Any, Any]],
NDArray[floating[Any]],
int32,
@@ -272,7 +270,7 @@ def norm(
def norm(
x: ArrayLike,
ord: None | float | L["fro", "nuc"] = ...,
- axis: SupportsInt | SupportsIndex | Tuple[int, ...] = ...,
+ axis: SupportsInt | SupportsIndex | tuple[int, ...] = ...,
keepdims: bool = ...,
) -> Any: ...
diff --git a/numpy/ma/__init__.pyi b/numpy/ma/__init__.pyi
index 26d44b508..377c63569 100644
--- a/numpy/ma/__init__.pyi
+++ b/numpy/ma/__init__.pyi
@@ -1,4 +1,4 @@
-from typing import Any, List
+from typing import Any
from numpy._pytesttester import PytestTester
@@ -231,6 +231,6 @@ from numpy.ma.extras import (
vstack as vstack,
)
-__all__: List[str]
-__path__: List[str]
+__all__: list[str]
+__path__: list[str]
test: PytestTester
diff --git a/numpy/ma/core.pyi b/numpy/ma/core.pyi
index bc1f45a8d..ff769a8d4 100644
--- a/numpy/ma/core.pyi
+++ b/numpy/ma/core.pyi
@@ -1,4 +1,4 @@
-from typing import Any, List, TypeVar, Callable
+from typing import Any, TypeVar, Callable
from numpy import ndarray, dtype, float64
from numpy import (
@@ -23,7 +23,7 @@ from numpy.lib.function_base import (
_ShapeType = TypeVar("_ShapeType", bound=Any)
_DType_co = TypeVar("_DType_co", bound=dtype[Any], covariant=True)
-__all__: List[str]
+__all__: list[str]
MaskType = bool_
nomask: bool_
diff --git a/numpy/ma/extras.pyi b/numpy/ma/extras.pyi
index e58e43bad..e66d7cb63 100644
--- a/numpy/ma/extras.pyi
+++ b/numpy/ma/extras.pyi
@@ -1,4 +1,4 @@
-from typing import Any, List
+from typing import Any
from numpy.lib.index_tricks import AxisConcatenator
from numpy.ma.core import (
@@ -6,7 +6,7 @@ from numpy.ma.core import (
mask_rowcols as mask_rowcols,
)
-__all__: List[str]
+__all__: list[str]
def count_masked(arr, axis=...): ...
def masked_all(shape, dtype = ...): ...
diff --git a/numpy/ma/mrecords.pyi b/numpy/ma/mrecords.pyi
index 7bd8678cf..264807e05 100644
--- a/numpy/ma/mrecords.pyi
+++ b/numpy/ma/mrecords.pyi
@@ -1,9 +1,9 @@
-from typing import List, Any, TypeVar
+from typing import Any, TypeVar
from numpy import dtype
from numpy.ma import MaskedArray
-__all__: List[str]
+__all__: list[str]
# TODO: Set the `bound` to something more suitable once we
# have proper shape support
@@ -84,7 +84,7 @@ def fromtextfile(
varnames=...,
vartypes=...,
# NOTE: deprecated: NumPy 1.22.0, 2021-09-23
- # delimitor=...,
+ # delimitor=...,
): ...
def addfield(mrecord, newfield, newfieldname=...): ...
diff --git a/numpy/matrixlib/__init__.pyi b/numpy/matrixlib/__init__.pyi
index c1b82d2ec..b0ca8c9ca 100644
--- a/numpy/matrixlib/__init__.pyi
+++ b/numpy/matrixlib/__init__.pyi
@@ -1,5 +1,3 @@
-from typing import List
-
from numpy._pytesttester import PytestTester
from numpy import (
@@ -12,6 +10,6 @@ from numpy.matrixlib.defmatrix import (
asmatrix as asmatrix,
)
-__all__: List[str]
-__path__: List[str]
+__all__: list[str]
+__path__: list[str]
test: PytestTester
diff --git a/numpy/matrixlib/defmatrix.pyi b/numpy/matrixlib/defmatrix.pyi
index 6c86ea1ef..91c7fa81d 100644
--- a/numpy/matrixlib/defmatrix.pyi
+++ b/numpy/matrixlib/defmatrix.pyi
@@ -1,8 +1,8 @@
-from typing import List, Any, Sequence, Mapping
+from typing import Any, Sequence, Mapping
from numpy import matrix as matrix
from numpy.typing import ArrayLike, DTypeLike, NDArray
-__all__: List[str]
+__all__: list[str]
def bmat(
obj: str | Sequence[ArrayLike] | NDArray[Any],
diff --git a/numpy/polynomial/__init__.pyi b/numpy/polynomial/__init__.pyi
index e0cfedd7a..c9d1c27a9 100644
--- a/numpy/polynomial/__init__.pyi
+++ b/numpy/polynomial/__init__.pyi
@@ -1,5 +1,3 @@
-from typing import List
-
from numpy._pytesttester import PytestTester
from numpy.polynomial import (
@@ -17,8 +15,8 @@ from numpy.polynomial.laguerre import Laguerre as Laguerre
from numpy.polynomial.legendre import Legendre as Legendre
from numpy.polynomial.polynomial import Polynomial as Polynomial
-__all__: List[str]
-__path__: List[str]
+__all__: list[str]
+__path__: list[str]
test: PytestTester
def set_default_printstyle(style): ...
diff --git a/numpy/polynomial/_polybase.pyi b/numpy/polynomial/_polybase.pyi
index c41601469..537221c45 100644
--- a/numpy/polynomial/_polybase.pyi
+++ b/numpy/polynomial/_polybase.pyi
@@ -1,7 +1,7 @@
import abc
-from typing import Any, List, ClassVar
+from typing import Any, ClassVar
-__all__: List[str]
+__all__: list[str]
class ABCPolyBase(abc.ABC):
__hash__: ClassVar[None] # type: ignore[assignment]
diff --git a/numpy/polynomial/chebyshev.pyi b/numpy/polynomial/chebyshev.pyi
index 841c0859b..e8113dbae 100644
--- a/numpy/polynomial/chebyshev.pyi
+++ b/numpy/polynomial/chebyshev.pyi
@@ -1,10 +1,10 @@
-from typing import Any, List
+from typing import Any
from numpy import ndarray, dtype, int_
from numpy.polynomial._polybase import ABCPolyBase
from numpy.polynomial.polyutils import trimcoef
-__all__: List[str]
+__all__: list[str]
chebtrim = trimcoef
diff --git a/numpy/polynomial/hermite.pyi b/numpy/polynomial/hermite.pyi
index 8364a5b0f..0d3556d69 100644
--- a/numpy/polynomial/hermite.pyi
+++ b/numpy/polynomial/hermite.pyi
@@ -1,4 +1,4 @@
-from typing import Any, List
+from typing import Any
from numpy import ndarray, dtype, int_, float_
from numpy.polynomial._polybase import ABCPolyBase
diff --git a/numpy/polynomial/hermite_e.pyi b/numpy/polynomial/hermite_e.pyi
index c029bfda7..0b7152a25 100644
--- a/numpy/polynomial/hermite_e.pyi
+++ b/numpy/polynomial/hermite_e.pyi
@@ -1,4 +1,4 @@
-from typing import Any, List
+from typing import Any
from numpy import ndarray, dtype, int_
from numpy.polynomial._polybase import ABCPolyBase
diff --git a/numpy/polynomial/laguerre.pyi b/numpy/polynomial/laguerre.pyi
index 2b9ab34e0..e546bc20a 100644
--- a/numpy/polynomial/laguerre.pyi
+++ b/numpy/polynomial/laguerre.pyi
@@ -1,4 +1,4 @@
-from typing import Any, List
+from typing import Any
from numpy import ndarray, dtype, int_
from numpy.polynomial._polybase import ABCPolyBase
diff --git a/numpy/polynomial/legendre.pyi b/numpy/polynomial/legendre.pyi
index 86aef1793..63a1c3f3a 100644
--- a/numpy/polynomial/legendre.pyi
+++ b/numpy/polynomial/legendre.pyi
@@ -1,4 +1,4 @@
-from typing import Any, List
+from typing import Any
from numpy import ndarray, dtype, int_
from numpy.polynomial._polybase import ABCPolyBase
diff --git a/numpy/polynomial/polynomial.pyi b/numpy/polynomial/polynomial.pyi
index f779300a9..3c87f9d29 100644
--- a/numpy/polynomial/polynomial.pyi
+++ b/numpy/polynomial/polynomial.pyi
@@ -1,4 +1,4 @@
-from typing import Any, List
+from typing import Any
from numpy import ndarray, dtype, int_
from numpy.polynomial._polybase import ABCPolyBase
diff --git a/numpy/polynomial/polyutils.pyi b/numpy/polynomial/polyutils.pyi
index 52c9cfc4a..06260a9f1 100644
--- a/numpy/polynomial/polyutils.pyi
+++ b/numpy/polynomial/polyutils.pyi
@@ -1,6 +1,4 @@
-from typing import List
-
-__all__: List[str]
+__all__: list[str]
class RankWarning(UserWarning): ...
diff --git a/numpy/random/__init__.pyi b/numpy/random/__init__.pyi
index bf6147697..32bd64a0b 100644
--- a/numpy/random/__init__.pyi
+++ b/numpy/random/__init__.pyi
@@ -1,5 +1,3 @@
-from typing import List
-
from numpy._pytesttester import PytestTester
from numpy.random._generator import Generator as Generator
@@ -67,6 +65,6 @@ from numpy.random.mtrand import (
zipf as zipf,
)
-__all__: List[str]
-__path__: List[str]
+__all__: list[str]
+__path__: list[str]
test: PytestTester
diff --git a/numpy/random/_generator.pyi b/numpy/random/_generator.pyi
index a1e25871a..ebfc6a770 100644
--- a/numpy/random/_generator.pyi
+++ b/numpy/random/_generator.pyi
@@ -1,4 +1,4 @@
-from typing import Any, Callable, Dict, Tuple, Type, Union, overload, TypeVar, Literal
+from typing import Any, Callable, Union, overload, TypeVar, Literal
from numpy import (
bool_,
@@ -48,7 +48,7 @@ _ArrayType = TypeVar("_ArrayType", bound=ndarray[Any, Any])
_DTypeLikeFloat32 = Union[
dtype[float32],
_SupportsDType[dtype[float32]],
- Type[float32],
+ type[float32],
_Float32Codes,
_SingleCodes,
]
@@ -56,8 +56,8 @@ _DTypeLikeFloat32 = Union[
_DTypeLikeFloat64 = Union[
dtype[float64],
_SupportsDType[dtype[float64]],
- Type[float],
- Type[float64],
+ type[float],
+ type[float64],
_Float64Codes,
_DoubleCodes,
]
@@ -66,9 +66,9 @@ class Generator:
def __init__(self, bit_generator: BitGenerator) -> None: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
- def __getstate__(self) -> Dict[str, Any]: ...
- def __setstate__(self, state: Dict[str, Any]) -> None: ...
- def __reduce__(self) -> Tuple[Callable[[str], Generator], Tuple[str], Dict[str, Any]]: ...
+ def __getstate__(self) -> dict[str, Any]: ...
+ def __setstate__(self, state: dict[str, Any]) -> None: ...
+ def __reduce__(self) -> tuple[Callable[[str], Generator], tuple[str], dict[str, Any]]: ...
@property
def bit_generator(self) -> BitGenerator: ...
def bytes(self, length: int) -> bytes: ...
@@ -243,7 +243,7 @@ class Generator:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[int8] | Type[int8] | _Int8Codes | _SupportsDType[dtype[int8]] = ...,
+ dtype: dtype[int8] | type[int8] | _Int8Codes | _SupportsDType[dtype[int8]] = ...,
endpoint: bool = ...,
) -> ndarray[Any, dtype[int8]]: ...
@overload
@@ -252,7 +252,7 @@ class Generator:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[int16] | Type[int16] | _Int16Codes | _SupportsDType[dtype[int16]] = ...,
+ dtype: dtype[int16] | type[int16] | _Int16Codes | _SupportsDType[dtype[int16]] = ...,
endpoint: bool = ...,
) -> ndarray[Any, dtype[int16]]: ...
@overload
@@ -261,7 +261,7 @@ class Generator:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[int32] | Type[int32] | _Int32Codes | _SupportsDType[dtype[int32]] = ...,
+ dtype: dtype[int32] | type[int32] | _Int32Codes | _SupportsDType[dtype[int32]] = ...,
endpoint: bool = ...,
) -> ndarray[Any, dtype[int32]]: ...
@overload
@@ -270,7 +270,7 @@ class Generator:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: None | dtype[int64] | Type[int64] | _Int64Codes | _SupportsDType[dtype[int64]] = ...,
+ dtype: None | dtype[int64] | type[int64] | _Int64Codes | _SupportsDType[dtype[int64]] = ...,
endpoint: bool = ...,
) -> ndarray[Any, dtype[int64]]: ...
@overload
@@ -279,7 +279,7 @@ class Generator:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[uint8] | Type[uint8] | _UInt8Codes | _SupportsDType[dtype[uint8]] = ...,
+ dtype: dtype[uint8] | type[uint8] | _UInt8Codes | _SupportsDType[dtype[uint8]] = ...,
endpoint: bool = ...,
) -> ndarray[Any, dtype[uint8]]: ...
@overload
@@ -288,7 +288,7 @@ class Generator:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[uint16] | Type[uint16] | _UInt16Codes | _SupportsDType[dtype[uint16]] = ...,
+ dtype: dtype[uint16] | type[uint16] | _UInt16Codes | _SupportsDType[dtype[uint16]] = ...,
endpoint: bool = ...,
) -> ndarray[Any, dtype[uint16]]: ...
@overload
@@ -297,7 +297,7 @@ class Generator:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[uint32] | Type[uint32] | _UInt32Codes | _SupportsDType[dtype[uint32]] = ...,
+ dtype: dtype[uint32] | type[uint32] | _UInt32Codes | _SupportsDType[dtype[uint32]] = ...,
endpoint: bool = ...,
) -> ndarray[Any, dtype[uint32]]: ...
@overload
@@ -306,7 +306,7 @@ class Generator:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[uint64] | Type[uint64] | _UInt64Codes | _SupportsDType[dtype[uint64]] = ...,
+ dtype: dtype[uint64] | type[uint64] | _UInt64Codes | _SupportsDType[dtype[uint64]] = ...,
endpoint: bool = ...,
) -> ndarray[Any, dtype[uint64]]: ...
@overload
@@ -315,7 +315,7 @@ class Generator:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[int_] | Type[int] | Type[int_] | _IntCodes | _SupportsDType[dtype[int_]] = ...,
+ dtype: dtype[int_] | type[int] | type[int_] | _IntCodes | _SupportsDType[dtype[int_]] = ...,
endpoint: bool = ...,
) -> ndarray[Any, dtype[int_]]: ...
@overload
@@ -324,7 +324,7 @@ class Generator:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[uint] | Type[uint] | _UIntCodes | _SupportsDType[dtype[uint]] = ...,
+ dtype: dtype[uint] | type[uint] | _UIntCodes | _SupportsDType[dtype[uint]] = ...,
endpoint: bool = ...,
) -> ndarray[Any, dtype[uint]]: ...
# TODO: Use a TypeVar _T here to get away from Any output? Should be int->ndarray[Any,dtype[int64]], ArrayLike[_T] -> _T | ndarray[Any,Any]
diff --git a/numpy/random/bit_generator.pyi b/numpy/random/bit_generator.pyi
index 071301e5d..d6dac98e6 100644
--- a/numpy/random/bit_generator.pyi
+++ b/numpy/random/bit_generator.pyi
@@ -3,13 +3,9 @@ from threading import Lock
from typing import (
Any,
Callable,
- Dict,
- List,
Mapping,
NamedTuple,
Sequence,
- Tuple,
- Type,
TypedDict,
TypeVar,
Union,
@@ -25,19 +21,19 @@ _T = TypeVar("_T")
_DTypeLikeUint32 = Union[
dtype[uint32],
_SupportsDType[dtype[uint32]],
- Type[uint32],
+ type[uint32],
_UInt32Codes,
]
_DTypeLikeUint64 = Union[
dtype[uint64],
_SupportsDType[dtype[uint64]],
- Type[uint64],
+ type[uint64],
_UInt64Codes,
]
class _SeedSeqState(TypedDict):
entropy: None | int | Sequence[int]
- spawn_key: Tuple[int, ...]
+ spawn_key: tuple[int, ...]
pool_size: int
n_children_spawned: int
@@ -57,17 +53,17 @@ class ISeedSequence(abc.ABC):
class ISpawnableSeedSequence(ISeedSequence):
@abc.abstractmethod
- def spawn(self: _T, n_children: int) -> List[_T]: ...
+ def spawn(self: _T, n_children: int) -> list[_T]: ...
class SeedlessSeedSequence(ISpawnableSeedSequence):
def generate_state(
self, n_words: int, dtype: _DTypeLikeUint32 | _DTypeLikeUint64 = ...
) -> ndarray[Any, dtype[uint32 | uint64]]: ...
- def spawn(self: _T, n_children: int) -> List[_T]: ...
+ def spawn(self: _T, n_children: int) -> list[_T]: ...
class SeedSequence(ISpawnableSeedSequence):
entropy: None | int | Sequence[int]
- spawn_key: Tuple[int, ...]
+ spawn_key: tuple[int, ...]
pool_size: int
n_children_spawned: int
pool: ndarray[Any, dtype[uint32]]
@@ -87,16 +83,16 @@ class SeedSequence(ISpawnableSeedSequence):
def generate_state(
self, n_words: int, dtype: _DTypeLikeUint32 | _DTypeLikeUint64 = ...
) -> ndarray[Any, dtype[uint32 | uint64]]: ...
- def spawn(self, n_children: int) -> List[SeedSequence]: ...
+ def spawn(self, n_children: int) -> list[SeedSequence]: ...
class BitGenerator(abc.ABC):
lock: Lock
def __init__(self, seed: None | _ArrayLikeInt_co | SeedSequence = ...) -> None: ...
- def __getstate__(self) -> Dict[str, Any]: ...
- def __setstate__(self, state: Dict[str, Any]) -> None: ...
+ def __getstate__(self) -> dict[str, Any]: ...
+ def __setstate__(self, state: dict[str, Any]) -> None: ...
def __reduce__(
self,
- ) -> Tuple[Callable[[str], BitGenerator], Tuple[str], Tuple[Dict[str, Any]]]: ...
+ ) -> tuple[Callable[[str], BitGenerator], tuple[str], tuple[dict[str, Any]]]: ...
@abc.abstractmethod
@property
def state(self) -> Mapping[str, Any]: ...
diff --git a/numpy/random/mtrand.pyi b/numpy/random/mtrand.pyi
index 87bdf8141..d9ecb80f9 100644
--- a/numpy/random/mtrand.pyi
+++ b/numpy/random/mtrand.pyi
@@ -1,4 +1,4 @@
-from typing import Any, Callable, Dict, Tuple, Type, Union, overload, Literal
+from typing import Any, Callable, Union, overload, Literal
from numpy import (
bool_,
@@ -46,7 +46,7 @@ from numpy.typing import (
_DTypeLikeFloat32 = Union[
dtype[float32],
_SupportsDType[dtype[float32]],
- Type[float32],
+ type[float32],
_Float32Codes,
_SingleCodes,
]
@@ -54,8 +54,8 @@ _DTypeLikeFloat32 = Union[
_DTypeLikeFloat64 = Union[
dtype[float64],
_SupportsDType[dtype[float64]],
- Type[float],
- Type[float64],
+ type[float],
+ type[float64],
_Float64Codes,
_DoubleCodes,
]
@@ -65,18 +65,18 @@ class RandomState:
def __init__(self, seed: None | _ArrayLikeInt_co | BitGenerator = ...) -> None: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
- def __getstate__(self) -> Dict[str, Any]: ...
- def __setstate__(self, state: Dict[str, Any]) -> None: ...
- def __reduce__(self) -> Tuple[Callable[[str], RandomState], Tuple[str], Dict[str, Any]]: ...
+ def __getstate__(self) -> dict[str, Any]: ...
+ def __setstate__(self, state: dict[str, Any]) -> None: ...
+ def __reduce__(self) -> tuple[Callable[[str], RandomState], tuple[str], dict[str, Any]]: ...
def seed(self, seed: None | _ArrayLikeFloat_co = ...) -> None: ...
@overload
- def get_state(self, legacy: Literal[False] = ...) -> Dict[str, Any]: ...
+ def get_state(self, legacy: Literal[False] = ...) -> dict[str, Any]: ...
@overload
def get_state(
self, legacy: Literal[True] = ...
- ) -> Dict[str, Any] | Tuple[str, ndarray[Any, dtype[uint32]], int, int, float]: ...
+ ) -> dict[str, Any] | tuple[str, ndarray[Any, dtype[uint32]], int, int, float]: ...
def set_state(
- self, state: Dict[str, Any] | Tuple[str, ndarray[Any, dtype[uint32]], int, int, float]
+ self, state: dict[str, Any] | tuple[str, ndarray[Any, dtype[uint32]], int, int, float]
) -> None: ...
@overload
def random_sample(self, size: None = ...) -> float: ... # type: ignore[misc]
@@ -149,7 +149,7 @@ class RandomState:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[int8] | Type[int8] | _Int8Codes | _SupportsDType[dtype[int8]] = ...,
+ dtype: dtype[int8] | type[int8] | _Int8Codes | _SupportsDType[dtype[int8]] = ...,
) -> ndarray[Any, dtype[int8]]: ...
@overload
def randint( # type: ignore[misc]
@@ -157,7 +157,7 @@ class RandomState:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[int16] | Type[int16] | _Int16Codes | _SupportsDType[dtype[int16]] = ...,
+ dtype: dtype[int16] | type[int16] | _Int16Codes | _SupportsDType[dtype[int16]] = ...,
) -> ndarray[Any, dtype[int16]]: ...
@overload
def randint( # type: ignore[misc]
@@ -165,7 +165,7 @@ class RandomState:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[int32] | Type[int32] | _Int32Codes | _SupportsDType[dtype[int32]] = ...,
+ dtype: dtype[int32] | type[int32] | _Int32Codes | _SupportsDType[dtype[int32]] = ...,
) -> ndarray[Any, dtype[int32]]: ...
@overload
def randint( # type: ignore[misc]
@@ -173,7 +173,7 @@ class RandomState:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: None | dtype[int64] | Type[int64] | _Int64Codes | _SupportsDType[dtype[int64]] = ...,
+ dtype: None | dtype[int64] | type[int64] | _Int64Codes | _SupportsDType[dtype[int64]] = ...,
) -> ndarray[Any, dtype[int64]]: ...
@overload
def randint( # type: ignore[misc]
@@ -181,7 +181,7 @@ class RandomState:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[uint8] | Type[uint8] | _UInt8Codes | _SupportsDType[dtype[uint8]] = ...,
+ dtype: dtype[uint8] | type[uint8] | _UInt8Codes | _SupportsDType[dtype[uint8]] = ...,
) -> ndarray[Any, dtype[uint8]]: ...
@overload
def randint( # type: ignore[misc]
@@ -189,7 +189,7 @@ class RandomState:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[uint16] | Type[uint16] | _UInt16Codes | _SupportsDType[dtype[uint16]] = ...,
+ dtype: dtype[uint16] | type[uint16] | _UInt16Codes | _SupportsDType[dtype[uint16]] = ...,
) -> ndarray[Any, dtype[uint16]]: ...
@overload
def randint( # type: ignore[misc]
@@ -197,7 +197,7 @@ class RandomState:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[uint32] | Type[uint32] | _UInt32Codes | _SupportsDType[dtype[uint32]] = ...,
+ dtype: dtype[uint32] | type[uint32] | _UInt32Codes | _SupportsDType[dtype[uint32]] = ...,
) -> ndarray[Any, dtype[uint32]]: ...
@overload
def randint( # type: ignore[misc]
@@ -205,7 +205,7 @@ class RandomState:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[uint64] | Type[uint64] | _UInt64Codes | _SupportsDType[dtype[uint64]] = ...,
+ dtype: dtype[uint64] | type[uint64] | _UInt64Codes | _SupportsDType[dtype[uint64]] = ...,
) -> ndarray[Any, dtype[uint64]]: ...
@overload
def randint( # type: ignore[misc]
@@ -213,7 +213,7 @@ class RandomState:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[int_] | Type[int] | Type[int_] | _IntCodes | _SupportsDType[dtype[int_]] = ...,
+ dtype: dtype[int_] | type[int] | type[int_] | _IntCodes | _SupportsDType[dtype[int_]] = ...,
) -> ndarray[Any, dtype[int_]]: ...
@overload
def randint( # type: ignore[misc]
@@ -221,7 +221,7 @@ class RandomState:
low: _ArrayLikeInt_co,
high: None | _ArrayLikeInt_co = ...,
size: None | _ShapeLike = ...,
- dtype: dtype[uint] | Type[uint] | _UIntCodes | _SupportsDType[dtype[uint]] = ...,
+ dtype: dtype[uint] | type[uint] | _UIntCodes | _SupportsDType[dtype[uint]] = ...,
) -> ndarray[Any, dtype[uint]]: ...
def bytes(self, length: int) -> bytes: ...
@overload
diff --git a/numpy/testing/__init__.pyi b/numpy/testing/__init__.pyi
index def0f9f58..a981d6113 100644
--- a/numpy/testing/__init__.pyi
+++ b/numpy/testing/__init__.pyi
@@ -1,5 +1,3 @@
-from typing import List
-
from numpy._pytesttester import PytestTester
from unittest import (
@@ -48,11 +46,11 @@ from numpy.testing._private.utils import (
HAS_LAPACK64 as HAS_LAPACK64,
)
-__all__: List[str]
-__path__: List[str]
+__all__: list[str]
+__path__: list[str]
test: PytestTester
def run_module_suite(
file_to_run: None | str = ...,
- argv: None | List[str] = ...,
+ argv: None | list[str] = ...,
) -> None: ...
diff --git a/numpy/testing/_private/utils.pyi b/numpy/testing/_private/utils.pyi
index 4ba5d82ee..ab3e6f805 100644
--- a/numpy/testing/_private/utils.pyi
+++ b/numpy/testing/_private/utils.pyi
@@ -11,16 +11,11 @@ from typing import (
AnyStr,
Callable,
ClassVar,
- Dict,
Iterable,
- List,
NoReturn,
overload,
Pattern,
Sequence,
- Set,
- Tuple,
- Type,
type_check_only,
TypeVar,
Union,
@@ -59,14 +54,14 @@ _ComparisonFunc = Callable[
],
]
-__all__: List[str]
+__all__: list[str]
class KnownFailureException(Exception): ...
class IgnoreException(Exception): ...
class clear_and_catch_warnings(warnings.catch_warnings):
- class_modules: ClassVar[Tuple[types.ModuleType, ...]]
- modules: Set[types.ModuleType]
+ class_modules: ClassVar[tuple[types.ModuleType, ...]]
+ modules: set[types.ModuleType]
@overload
def __new__(
cls,
@@ -85,10 +80,10 @@ class clear_and_catch_warnings(warnings.catch_warnings):
record: bool,
modules: Iterable[types.ModuleType] = ...,
) -> clear_and_catch_warnings: ...
- def __enter__(self) -> None | List[warnings.WarningMessage]: ...
+ def __enter__(self) -> None | list[warnings.WarningMessage]: ...
def __exit__(
self,
- __exc_type: None | Type[BaseException] = ...,
+ __exc_type: None | type[BaseException] = ...,
__exc_val: None | BaseException = ...,
__exc_tb: None | types.TracebackType = ...,
) -> None: ...
@@ -98,34 +93,34 @@ class clear_and_catch_warnings(warnings.catch_warnings):
@type_check_only
class _clear_and_catch_warnings_with_records(clear_and_catch_warnings):
- def __enter__(self) -> List[warnings.WarningMessage]: ...
+ def __enter__(self) -> list[warnings.WarningMessage]: ...
@type_check_only
class _clear_and_catch_warnings_without_records(clear_and_catch_warnings):
def __enter__(self) -> None: ...
class suppress_warnings:
- log: List[warnings.WarningMessage]
+ log: list[warnings.WarningMessage]
def __init__(
self,
forwarding_rule: L["always", "module", "once", "location"] = ...,
) -> None: ...
def filter(
self,
- category: Type[Warning] = ...,
+ category: type[Warning] = ...,
message: str = ...,
module: None | types.ModuleType = ...,
) -> None: ...
def record(
self,
- category: Type[Warning] = ...,
+ category: type[Warning] = ...,
message: str = ...,
module: None | types.ModuleType = ...,
- ) -> List[warnings.WarningMessage]: ...
+ ) -> list[warnings.WarningMessage]: ...
def __enter__(self: _T) -> _T: ...
def __exit__(
self,
- __exc_type: None | Type[BaseException] = ...,
+ __exc_type: None | type[BaseException] = ...,
__exc_val: None | BaseException = ...,
__exc_tb: None | types.TracebackType = ...,
) -> None: ...
@@ -151,10 +146,10 @@ else:
if sys.platform == "linux":
def jiffies(
_proc_pid_stat: str | bytes | os.PathLike[Any] = ...,
- _load_time: List[float] = ...,
+ _load_time: list[float] = ...,
) -> int: ...
else:
- def jiffies(_load_time: List[float] = ...) -> int: ...
+ def jiffies(_load_time: list[float] = ...) -> int: ...
def build_err_msg(
arrays: Iterable[object],
@@ -246,7 +241,7 @@ def assert_array_less(
def runstring(
astr: str | bytes | types.CodeType,
- dict: None | Dict[str, Any],
+ dict: None | dict[str, Any],
) -> Any: ...
def assert_string_equal(actual: str, desired: str) -> None: ...
@@ -256,11 +251,11 @@ def rundocs(
raise_on_error: bool = ...,
) -> None: ...
-def raises(*args: Type[BaseException]) -> Callable[[_FT], _FT]: ...
+def raises(*args: type[BaseException]) -> Callable[[_FT], _FT]: ...
@overload
def assert_raises( # type: ignore
- expected_exception: Type[BaseException] | Tuple[Type[BaseException], ...],
+ expected_exception: type[BaseException] | tuple[type[BaseException], ...],
callable: Callable[..., Any],
/,
*args: Any,
@@ -268,14 +263,14 @@ def assert_raises( # type: ignore
) -> None: ...
@overload
def assert_raises(
- expected_exception: Type[_ET] | Tuple[Type[_ET], ...],
+ expected_exception: type[_ET] | tuple[type[_ET], ...],
*,
msg: None | str = ...,
) -> unittest.case._AssertRaisesContext[_ET]: ...
@overload
def assert_raises_regex(
- expected_exception: Type[BaseException] | Tuple[Type[BaseException], ...],
+ expected_exception: type[BaseException] | tuple[type[BaseException], ...],
expected_regex: str | bytes | Pattern[Any],
callable: Callable[..., Any],
/,
@@ -284,14 +279,14 @@ def assert_raises_regex(
) -> None: ...
@overload
def assert_raises_regex(
- expected_exception: Type[_ET] | Tuple[Type[_ET], ...],
+ expected_exception: type[_ET] | tuple[type[_ET], ...],
expected_regex: str | bytes | Pattern[Any],
*,
msg: None | str = ...,
) -> unittest.case._AssertRaisesContext[_ET]: ...
def decorate_methods(
- cls: Type[Any],
+ cls: type[Any],
decorator: Callable[[Callable[..., Any]], Any],
testmatch: None | str | bytes | Pattern[Any] = ...,
) -> None: ...
@@ -338,11 +333,11 @@ def assert_array_max_ulp(
@overload
def assert_warns(
- warning_class: Type[Warning],
+ warning_class: type[Warning],
) -> contextlib._GeneratorContextManager[None]: ...
@overload
def assert_warns(
- warning_class: Type[Warning],
+ warning_class: type[Warning],
func: Callable[..., _T],
/,
*args: Any,
diff --git a/numpy/typing/_callable.pyi b/numpy/typing/_callable.pyi
index 59af13e01..6d7136592 100644
--- a/numpy/typing/_callable.pyi
+++ b/numpy/typing/_callable.pyi
@@ -14,7 +14,6 @@ from typing import (
TypeVar,
overload,
Any,
- Tuple,
NoReturn,
Protocol,
)
@@ -50,7 +49,7 @@ _T1 = TypeVar("_T1")
_T2 = TypeVar("_T2")
_T1_contra = TypeVar("_T1_contra", contravariant=True)
_T2_contra = TypeVar("_T2_contra", contravariant=True)
-_2Tuple = Tuple[_T1, _T1]
+_2Tuple = tuple[_T1, _T1]
_NBit1 = TypeVar("_NBit1", bound=NBitBase)
_NBit2 = TypeVar("_NBit2", bound=NBitBase)
diff --git a/numpy/typing/_generic_alias.py b/numpy/typing/_generic_alias.py
index 1eb2c8c05..9579b22a4 100644
--- a/numpy/typing/_generic_alias.py
+++ b/numpy/typing/_generic_alias.py
@@ -5,14 +5,10 @@ import types
from typing import (
Any,
ClassVar,
- FrozenSet,
Generator,
Iterable,
Iterator,
- List,
NoReturn,
- Tuple,
- Type,
TypeVar,
TYPE_CHECKING,
)
@@ -93,38 +89,38 @@ class _GenericAlias:
return super().__getattribute__("_origin")
@property
- def __args__(self) -> Tuple[object, ...]:
+ def __args__(self) -> tuple[object, ...]:
return super().__getattribute__("_args")
@property
- def __parameters__(self) -> Tuple[TypeVar, ...]:
+ def __parameters__(self) -> tuple[TypeVar, ...]:
"""Type variables in the ``GenericAlias``."""
return super().__getattribute__("_parameters")
def __init__(
self,
origin: type,
- args: object | Tuple[object, ...],
+ args: object | tuple[object, ...],
) -> None:
self._origin = origin
self._args = args if isinstance(args, tuple) else (args,)
self._parameters = tuple(_parse_parameters(self.__args__))
@property
- def __call__(self) -> type:
+ def __call__(self) -> type[Any]:
return self.__origin__
- def __reduce__(self: _T) -> Tuple[
- Type[_T],
- Tuple[type, Tuple[object, ...]],
+ def __reduce__(self: _T) -> tuple[
+ type[_T],
+ tuple[type[Any], tuple[object, ...]],
]:
cls = type(self)
return cls, (self.__origin__, self.__args__)
- def __mro_entries__(self, bases: Iterable[object]) -> Tuple[type]:
+ def __mro_entries__(self, bases: Iterable[object]) -> tuple[type[Any]]:
return (self.__origin__,)
- def __dir__(self) -> List[str]:
+ def __dir__(self) -> list[str]:
"""Implement ``dir(self)``."""
cls = type(self)
dir_origin = set(dir(self.__origin__))
@@ -155,7 +151,7 @@ class _GenericAlias:
origin = _to_str(self.__origin__)
return f"{origin}[{args}]"
- def __getitem__(self: _T, key: object | Tuple[object, ...]) -> _T:
+ def __getitem__(self: _T, key: object | tuple[object, ...]) -> _T:
"""Return ``self[key]``."""
key_tup = key if isinstance(key, tuple) else (key,)
@@ -178,7 +174,7 @@ class _GenericAlias:
self.__args__ == value.__args__
)
- _ATTR_EXCEPTIONS: ClassVar[FrozenSet[str]] = frozenset({
+ _ATTR_EXCEPTIONS: ClassVar[frozenset[str]] = frozenset({
"__origin__",
"__args__",
"__parameters__",
diff --git a/numpy/typing/_ufunc.pyi b/numpy/typing/_ufunc.pyi
index 1be3500c1..703b7f925 100644
--- a/numpy/typing/_ufunc.pyi
+++ b/numpy/typing/_ufunc.pyi
@@ -10,9 +10,7 @@ four private subclasses, one for each combination of
from typing import (
Any,
Generic,
- List,
overload,
- Tuple,
TypeVar,
Literal,
SupportsIndex,
@@ -27,9 +25,9 @@ from ._array_like import ArrayLike, _ArrayLikeBool_co, _ArrayLikeInt_co
from ._dtype_like import DTypeLike
_T = TypeVar("_T")
-_2Tuple = Tuple[_T, _T]
-_3Tuple = Tuple[_T, _T, _T]
-_4Tuple = Tuple[_T, _T, _T, _T]
+_2Tuple = tuple[_T, _T]
+_3Tuple = tuple[_T, _T, _T]
+_4Tuple = tuple[_T, _T, _T, _T]
_NTypes = TypeVar("_NTypes", bound=int)
_IDType = TypeVar("_IDType", bound=Any)
@@ -86,13 +84,13 @@ class _UFunc_Nin1_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]):
dtype: DTypeLike = ...,
subok: bool = ...,
signature: str | _2Tuple[None | str] = ...,
- extobj: List[Any] = ...,
+ extobj: list[Any] = ...,
) -> Any: ...
@overload
def __call__(
self,
__x1: ArrayLike,
- out: None | NDArray[Any] | Tuple[NDArray[Any]] = ...,
+ out: None | NDArray[Any] | tuple[NDArray[Any]] = ...,
*,
where: None | _ArrayLikeBool_co = ...,
casting: _CastingKind = ...,
@@ -100,7 +98,7 @@ class _UFunc_Nin1_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]):
dtype: DTypeLike = ...,
subok: bool = ...,
signature: str | _2Tuple[None | str] = ...,
- extobj: List[Any] = ...,
+ extobj: list[Any] = ...,
) -> NDArray[Any]: ...
def at(
@@ -139,14 +137,14 @@ class _UFunc_Nin2_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]):
dtype: DTypeLike = ...,
subok: bool = ...,
signature: str | _3Tuple[None | str] = ...,
- extobj: List[Any] = ...,
+ extobj: list[Any] = ...,
) -> Any: ...
@overload
def __call__(
self,
__x1: ArrayLike,
__x2: ArrayLike,
- out: None | NDArray[Any] | Tuple[NDArray[Any]] = ...,
+ out: None | NDArray[Any] | tuple[NDArray[Any]] = ...,
*,
where: None | _ArrayLikeBool_co = ...,
casting: _CastingKind = ...,
@@ -154,7 +152,7 @@ class _UFunc_Nin2_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]):
dtype: DTypeLike = ...,
subok: bool = ...,
signature: str | _3Tuple[None | str] = ...,
- extobj: List[Any] = ...,
+ extobj: list[Any] = ...,
) -> NDArray[Any]: ...
def at(
@@ -207,7 +205,7 @@ class _UFunc_Nin2_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]):
dtype: DTypeLike = ...,
subok: bool = ...,
signature: str | _3Tuple[None | str] = ...,
- extobj: List[Any] = ...,
+ extobj: list[Any] = ...,
) -> Any: ...
@overload
def outer( # type: ignore[misc]
@@ -215,14 +213,14 @@ class _UFunc_Nin2_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]):
A: ArrayLike,
B: ArrayLike,
/, *,
- out: None | NDArray[Any] | Tuple[NDArray[Any]] = ...,
+ out: None | NDArray[Any] | tuple[NDArray[Any]] = ...,
where: None | _ArrayLikeBool_co = ...,
casting: _CastingKind = ...,
order: _OrderKACF = ...,
dtype: DTypeLike = ...,
subok: bool = ...,
signature: str | _3Tuple[None | str] = ...,
- extobj: List[Any] = ...,
+ extobj: list[Any] = ...,
) -> NDArray[Any]: ...
class _UFunc_Nin1_Nout2(ufunc, Generic[_NameType, _NTypes, _IDType]):
@@ -264,7 +262,7 @@ class _UFunc_Nin1_Nout2(ufunc, Generic[_NameType, _NTypes, _IDType]):
dtype: DTypeLike = ...,
subok: bool = ...,
signature: str | _3Tuple[None | str] = ...,
- extobj: List[Any] = ...,
+ extobj: list[Any] = ...,
) -> _2Tuple[Any]: ...
@overload
def __call__(
@@ -280,7 +278,7 @@ class _UFunc_Nin1_Nout2(ufunc, Generic[_NameType, _NTypes, _IDType]):
dtype: DTypeLike = ...,
subok: bool = ...,
signature: str | _3Tuple[None | str] = ...,
- extobj: List[Any] = ...,
+ extobj: list[Any] = ...,
) -> _2Tuple[NDArray[Any]]: ...
class _UFunc_Nin2_Nout2(ufunc, Generic[_NameType, _NTypes, _IDType]):
@@ -323,7 +321,7 @@ class _UFunc_Nin2_Nout2(ufunc, Generic[_NameType, _NTypes, _IDType]):
dtype: DTypeLike = ...,
subok: bool = ...,
signature: str | _4Tuple[None | str] = ...,
- extobj: List[Any] = ...,
+ extobj: list[Any] = ...,
) -> _2Tuple[Any]: ...
@overload
def __call__(
@@ -340,7 +338,7 @@ class _UFunc_Nin2_Nout2(ufunc, Generic[_NameType, _NTypes, _IDType]):
dtype: DTypeLike = ...,
subok: bool = ...,
signature: str | _4Tuple[None | str] = ...,
- extobj: List[Any] = ...,
+ extobj: list[Any] = ...,
) -> _2Tuple[NDArray[Any]]: ...
class _GUFunc_Nin2_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]):
@@ -385,21 +383,21 @@ class _GUFunc_Nin2_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]):
dtype: DTypeLike = ...,
subok: bool = ...,
signature: str | _3Tuple[None | str] = ...,
- extobj: List[Any] = ...,
- axes: List[_2Tuple[SupportsIndex]] = ...,
+ extobj: list[Any] = ...,
+ axes: list[_2Tuple[SupportsIndex]] = ...,
) -> Any: ...
@overload
def __call__(
self,
__x1: ArrayLike,
__x2: ArrayLike,
- out: NDArray[Any] | Tuple[NDArray[Any]],
+ out: NDArray[Any] | tuple[NDArray[Any]],
*,
casting: _CastingKind = ...,
order: _OrderKACF = ...,
dtype: DTypeLike = ...,
subok: bool = ...,
signature: str | _3Tuple[None | str] = ...,
- extobj: List[Any] = ...,
- axes: List[_2Tuple[SupportsIndex]] = ...,
+ extobj: list[Any] = ...,
+ axes: list[_2Tuple[SupportsIndex]] = ...,
) -> NDArray[Any]: ...
diff --git a/numpy/typing/tests/data/fail/arithmetic.pyi b/numpy/typing/tests/data/fail/arithmetic.pyi
index b99b24c1f..3bbc101cf 100644
--- a/numpy/typing/tests/data/fail/arithmetic.pyi
+++ b/numpy/typing/tests/data/fail/arithmetic.pyi
@@ -1,4 +1,4 @@
-from typing import List, Any
+from typing import Any
import numpy as np
b_ = np.bool_()
@@ -15,13 +15,13 @@ AR_M: np.ndarray[Any, np.dtype[np.datetime64]]
ANY: Any
-AR_LIKE_b: List[bool]
-AR_LIKE_u: List[np.uint32]
-AR_LIKE_i: List[int]
-AR_LIKE_f: List[float]
-AR_LIKE_c: List[complex]
-AR_LIKE_m: List[np.timedelta64]
-AR_LIKE_M: List[np.datetime64]
+AR_LIKE_b: list[bool]
+AR_LIKE_u: list[np.uint32]
+AR_LIKE_i: list[int]
+AR_LIKE_f: list[float]
+AR_LIKE_c: list[complex]
+AR_LIKE_m: list[np.timedelta64]
+AR_LIKE_M: list[np.datetime64]
# Array subtraction
diff --git a/numpy/typing/tests/data/fail/einsumfunc.pyi b/numpy/typing/tests/data/fail/einsumfunc.pyi
index 33722f861..f0e3f1e95 100644
--- a/numpy/typing/tests/data/fail/einsumfunc.pyi
+++ b/numpy/typing/tests/data/fail/einsumfunc.pyi
@@ -1,4 +1,4 @@
-from typing import List, Any
+from typing import Any
import numpy as np
AR_i: np.ndarray[Any, np.dtype[np.int64]]
diff --git a/numpy/typing/tests/data/fail/index_tricks.pyi b/numpy/typing/tests/data/fail/index_tricks.pyi
index c508bf3ae..2bf2337db 100644
--- a/numpy/typing/tests/data/fail/index_tricks.pyi
+++ b/numpy/typing/tests/data/fail/index_tricks.pyi
@@ -1,8 +1,7 @@
-from typing import List
import numpy as np
-AR_LIKE_i: List[int]
-AR_LIKE_f: List[float]
+AR_LIKE_i: list[int]
+AR_LIKE_f: list[float]
np.unravel_index(AR_LIKE_f, (1, 2, 3)) # E: incompatible type
np.ravel_multi_index(AR_LIKE_i, (1, 2, 3), mode="bob") # E: No overload variant
diff --git a/numpy/typing/tests/data/fail/multiarray.pyi b/numpy/typing/tests/data/fail/multiarray.pyi
index 22bcf8c92..a770e52c5 100644
--- a/numpy/typing/tests/data/fail/multiarray.pyi
+++ b/numpy/typing/tests/data/fail/multiarray.pyi
@@ -1,4 +1,3 @@
-from typing import List
import numpy as np
import numpy.typing as npt
@@ -12,7 +11,7 @@ AR_M: npt.NDArray[np.datetime64]
M: np.datetime64
-AR_LIKE_f: List[float]
+AR_LIKE_f: list[float]
def func(a: int) -> None: ...
diff --git a/numpy/typing/tests/data/fail/nested_sequence.pyi b/numpy/typing/tests/data/fail/nested_sequence.pyi
index e28661a05..c51593b1e 100644
--- a/numpy/typing/tests/data/fail/nested_sequence.pyi
+++ b/numpy/typing/tests/data/fail/nested_sequence.pyi
@@ -1,9 +1,9 @@
-from typing import Sequence, Tuple, List
+from collections.abc import Sequence
import numpy.typing as npt
a: Sequence[float]
-b: List[complex]
-c: Tuple[str, ...]
+b: list[complex]
+c: tuple[str, ...]
d: int
e: str
diff --git a/numpy/typing/tests/data/fail/random.pyi b/numpy/typing/tests/data/fail/random.pyi
index c4d1e3e3e..f0e682019 100644
--- a/numpy/typing/tests/data/fail/random.pyi
+++ b/numpy/typing/tests/data/fail/random.pyi
@@ -1,9 +1,9 @@
import numpy as np
-from typing import Any, List
+from typing import Any
SEED_FLOAT: float = 457.3
SEED_ARR_FLOAT: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.0, 2, 3, 4])
-SEED_ARRLIKE_FLOAT: List[float] = [1.0, 2.0, 3.0, 4.0]
+SEED_ARRLIKE_FLOAT: list[float] = [1.0, 2.0, 3.0, 4.0]
SEED_SEED_SEQ: np.random.SeedSequence = np.random.SeedSequence(0)
SEED_STR: str = "String seeding not allowed"
# default rng
diff --git a/numpy/typing/tests/data/fail/twodim_base.pyi b/numpy/typing/tests/data/fail/twodim_base.pyi
index ab34a374c..faa430095 100644
--- a/numpy/typing/tests/data/fail/twodim_base.pyi
+++ b/numpy/typing/tests/data/fail/twodim_base.pyi
@@ -1,4 +1,4 @@
-from typing import Any, List, TypeVar
+from typing import Any, TypeVar
import numpy as np
import numpy.typing as npt
@@ -15,7 +15,7 @@ def func2(ar: npt.NDArray[Any], a: float) -> float:
AR_b: npt.NDArray[np.bool_]
AR_m: npt.NDArray[np.timedelta64]
-AR_LIKE_b: List[bool]
+AR_LIKE_b: list[bool]
np.eye(10, M=20.0) # E: No overload variant
np.eye(10, k=2.5, dtype=int) # E: No overload variant
diff --git a/numpy/typing/tests/data/fail/ufunclike.pyi b/numpy/typing/tests/data/fail/ufunclike.pyi
index 82a5f3a1d..2f9fd14c8 100644
--- a/numpy/typing/tests/data/fail/ufunclike.pyi
+++ b/numpy/typing/tests/data/fail/ufunclike.pyi
@@ -1,4 +1,4 @@
-from typing import List, Any
+from typing import Any
import numpy as np
AR_c: np.ndarray[Any, np.dtype[np.complex128]]
diff --git a/numpy/typing/tests/data/pass/literal.py b/numpy/typing/tests/data/pass/literal.py
index 8eaeb6afb..ad74b417d 100644
--- a/numpy/typing/tests/data/pass/literal.py
+++ b/numpy/typing/tests/data/pass/literal.py
@@ -1,5 +1,7 @@
+from __future__ import annotations
+
from functools import partial
-from typing import Callable, List, Tuple
+from typing import Callable
import pytest # type: ignore
import numpy as np
@@ -11,7 +13,7 @@ KACF = frozenset({None, "K", "A", "C", "F"})
ACF = frozenset({None, "A", "C", "F"})
CF = frozenset({None, "C", "F"})
-order_list: List[Tuple[frozenset, Callable]] = [
+order_list: list[tuple[frozenset, Callable]] = [
(KACF, partial(np.ndarray, 1)),
(KACF, AR.tobytes),
(KACF, partial(AR.astype, int)),
diff --git a/numpy/typing/tests/data/pass/numeric.py b/numpy/typing/tests/data/pass/numeric.py
index 34fef7270..c4a73c1e9 100644
--- a/numpy/typing/tests/data/pass/numeric.py
+++ b/numpy/typing/tests/data/pass/numeric.py
@@ -5,7 +5,8 @@ Does not include tests which fall under ``array_constructors``.
"""
-from typing import List
+from __future__ import annotations
+
import numpy as np
class SubClass(np.ndarray):
@@ -14,7 +15,7 @@ class SubClass(np.ndarray):
i8 = np.int64(1)
A = np.arange(27).reshape(3, 3, 3)
-B: List[List[List[int]]] = A.tolist()
+B: list[list[list[int]]] = A.tolist()
C = np.empty((27, 27)).view(SubClass)
np.count_nonzero(i8)
diff --git a/numpy/typing/tests/data/pass/random.py b/numpy/typing/tests/data/pass/random.py
index 05bd62112..9816cd2c3 100644
--- a/numpy/typing/tests/data/pass/random.py
+++ b/numpy/typing/tests/data/pass/random.py
@@ -1,13 +1,12 @@
from __future__ import annotations
-from typing import Any, List, Dict
-
+from typing import Any
import numpy as np
SEED_NONE = None
SEED_INT = 4579435749574957634658964293569
SEED_ARR: np.ndarray[Any, np.dtype[np.int64]] = np.array([1, 2, 3, 4], dtype=np.int64)
-SEED_ARRLIKE: List[int] = [1, 2, 3, 4]
+SEED_ARRLIKE: list[int] = [1, 2, 3, 4]
SEED_SEED_SEQ: np.random.SeedSequence = np.random.SeedSequence(0)
SEED_MT19937: np.random.MT19937 = np.random.MT19937(0)
SEED_PCG64: np.random.PCG64 = np.random.PCG64(0)
@@ -76,13 +75,13 @@ D_arr_0p9: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.9])
D_arr_1p5: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.5])
I_arr_10: np.ndarray[Any, np.dtype[np.int_]] = np.array([10], dtype=np.int_)
I_arr_20: np.ndarray[Any, np.dtype[np.int_]] = np.array([20], dtype=np.int_)
-D_arr_like_0p1: List[float] = [0.1]
-D_arr_like_0p5: List[float] = [0.5]
-D_arr_like_0p9: List[float] = [0.9]
-D_arr_like_1p5: List[float] = [1.5]
-I_arr_like_10: List[int] = [10]
-I_arr_like_20: List[int] = [20]
-D_2D_like: List[List[float]] = [[1, 2], [2, 3], [3, 4], [4, 5.1]]
+D_arr_like_0p1: list[float] = [0.1]
+D_arr_like_0p5: list[float] = [0.5]
+D_arr_like_0p9: list[float] = [0.9]
+D_arr_like_1p5: list[float] = [1.5]
+I_arr_like_10: list[int] = [10]
+I_arr_like_20: list[int] = [20]
+D_2D_like: list[list[float]] = [[1, 2], [2, 3], [3, 4], [4, 5.1]]
D_2D: np.ndarray[Any, np.dtype[np.float64]] = np.array(D_2D_like)
S_out: np.ndarray[Any, np.dtype[np.float32]] = np.empty(1, dtype=np.float32)
@@ -499,7 +498,7 @@ def_gen.integers([100])
def_gen.integers(0, [100])
I_bool_low: np.ndarray[Any, np.dtype[np.bool_]] = np.array([0], dtype=np.bool_)
-I_bool_low_like: List[int] = [0]
+I_bool_low_like: list[int] = [0]
I_bool_high_open: np.ndarray[Any, np.dtype[np.bool_]] = np.array([1], dtype=np.bool_)
I_bool_high_closed: np.ndarray[Any, np.dtype[np.bool_]] = np.array([1], dtype=np.bool_)
@@ -528,7 +527,7 @@ def_gen.integers(I_bool_low, I_bool_high_closed, dtype=np.bool_, endpoint=True)
def_gen.integers(0, I_bool_high_closed, dtype=np.bool_, endpoint=True)
I_u1_low: np.ndarray[Any, np.dtype[np.uint8]] = np.array([0], dtype=np.uint8)
-I_u1_low_like: List[int] = [0]
+I_u1_low_like: list[int] = [0]
I_u1_high_open: np.ndarray[Any, np.dtype[np.uint8]] = np.array([255], dtype=np.uint8)
I_u1_high_closed: np.ndarray[Any, np.dtype[np.uint8]] = np.array([255], dtype=np.uint8)
@@ -569,7 +568,7 @@ def_gen.integers(I_u1_low, I_u1_high_closed, dtype=np.uint8, endpoint=True)
def_gen.integers(0, I_u1_high_closed, dtype=np.uint8, endpoint=True)
I_u2_low: np.ndarray[Any, np.dtype[np.uint16]] = np.array([0], dtype=np.uint16)
-I_u2_low_like: List[int] = [0]
+I_u2_low_like: list[int] = [0]
I_u2_high_open: np.ndarray[Any, np.dtype[np.uint16]] = np.array([65535], dtype=np.uint16)
I_u2_high_closed: np.ndarray[Any, np.dtype[np.uint16]] = np.array([65535], dtype=np.uint16)
@@ -610,7 +609,7 @@ def_gen.integers(I_u2_low, I_u2_high_closed, dtype=np.uint16, endpoint=True)
def_gen.integers(0, I_u2_high_closed, dtype=np.uint16, endpoint=True)
I_u4_low: np.ndarray[Any, np.dtype[np.uint32]] = np.array([0], dtype=np.uint32)
-I_u4_low_like: List[int] = [0]
+I_u4_low_like: list[int] = [0]
I_u4_high_open: np.ndarray[Any, np.dtype[np.uint32]] = np.array([4294967295], dtype=np.uint32)
I_u4_high_closed: np.ndarray[Any, np.dtype[np.uint32]] = np.array([4294967295], dtype=np.uint32)
@@ -651,7 +650,7 @@ def_gen.integers(I_u4_low, I_u4_high_closed, dtype=np.uint32, endpoint=True)
def_gen.integers(0, I_u4_high_closed, dtype=np.uint32, endpoint=True)
I_u8_low: np.ndarray[Any, np.dtype[np.uint64]] = np.array([0], dtype=np.uint64)
-I_u8_low_like: List[int] = [0]
+I_u8_low_like: list[int] = [0]
I_u8_high_open: np.ndarray[Any, np.dtype[np.uint64]] = np.array([18446744073709551615], dtype=np.uint64)
I_u8_high_closed: np.ndarray[Any, np.dtype[np.uint64]] = np.array([18446744073709551615], dtype=np.uint64)
@@ -692,7 +691,7 @@ def_gen.integers(I_u8_low, I_u8_high_closed, dtype=np.uint64, endpoint=True)
def_gen.integers(0, I_u8_high_closed, dtype=np.uint64, endpoint=True)
I_i1_low: np.ndarray[Any, np.dtype[np.int8]] = np.array([-128], dtype=np.int8)
-I_i1_low_like: List[int] = [-128]
+I_i1_low_like: list[int] = [-128]
I_i1_high_open: np.ndarray[Any, np.dtype[np.int8]] = np.array([127], dtype=np.int8)
I_i1_high_closed: np.ndarray[Any, np.dtype[np.int8]] = np.array([127], dtype=np.int8)
@@ -733,7 +732,7 @@ def_gen.integers(I_i1_low, I_i1_high_closed, dtype=np.int8, endpoint=True)
def_gen.integers(-128, I_i1_high_closed, dtype=np.int8, endpoint=True)
I_i2_low: np.ndarray[Any, np.dtype[np.int16]] = np.array([-32768], dtype=np.int16)
-I_i2_low_like: List[int] = [-32768]
+I_i2_low_like: list[int] = [-32768]
I_i2_high_open: np.ndarray[Any, np.dtype[np.int16]] = np.array([32767], dtype=np.int16)
I_i2_high_closed: np.ndarray[Any, np.dtype[np.int16]] = np.array([32767], dtype=np.int16)
@@ -774,7 +773,7 @@ def_gen.integers(I_i2_low, I_i2_high_closed, dtype=np.int16, endpoint=True)
def_gen.integers(-32768, I_i2_high_closed, dtype=np.int16, endpoint=True)
I_i4_low: np.ndarray[Any, np.dtype[np.int32]] = np.array([-2147483648], dtype=np.int32)
-I_i4_low_like: List[int] = [-2147483648]
+I_i4_low_like: list[int] = [-2147483648]
I_i4_high_open: np.ndarray[Any, np.dtype[np.int32]] = np.array([2147483647], dtype=np.int32)
I_i4_high_closed: np.ndarray[Any, np.dtype[np.int32]] = np.array([2147483647], dtype=np.int32)
@@ -815,7 +814,7 @@ def_gen.integers(I_i4_low, I_i4_high_closed, dtype=np.int32, endpoint=True)
def_gen.integers(-2147483648, I_i4_high_closed, dtype=np.int32, endpoint=True)
I_i8_low: np.ndarray[Any, np.dtype[np.int64]] = np.array([-9223372036854775808], dtype=np.int64)
-I_i8_low_like: List[int] = [-9223372036854775808]
+I_i8_low_like: list[int] = [-9223372036854775808]
I_i8_high_open: np.ndarray[Any, np.dtype[np.int64]] = np.array([9223372036854775807], dtype=np.int64)
I_i8_high_closed: np.ndarray[Any, np.dtype[np.int64]] = np.array([9223372036854775807], dtype=np.int64)
@@ -912,7 +911,7 @@ def_gen.shuffle(D_2D, axis=1)
def_gen.__str__()
def_gen.__repr__()
-def_gen_state: Dict[str, Any]
+def_gen_state: dict[str, Any]
def_gen_state = def_gen.__getstate__()
def_gen.__setstate__(def_gen_state)
diff --git a/numpy/typing/tests/data/reveal/arithmetic.pyi b/numpy/typing/tests/data/reveal/arithmetic.pyi
index c5b467469..2002727cf 100644
--- a/numpy/typing/tests/data/reveal/arithmetic.pyi
+++ b/numpy/typing/tests/data/reveal/arithmetic.pyi
@@ -1,4 +1,4 @@
-from typing import Any, List
+from typing import Any
import numpy as np
import numpy.typing as npt
@@ -34,14 +34,14 @@ AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
AR_M: np.ndarray[Any, np.dtype[np.datetime64]]
AR_O: np.ndarray[Any, np.dtype[np.object_]]
-AR_LIKE_b: List[bool]
-AR_LIKE_u: List[np.uint32]
-AR_LIKE_i: List[int]
-AR_LIKE_f: List[float]
-AR_LIKE_c: List[complex]
-AR_LIKE_m: List[np.timedelta64]
-AR_LIKE_M: List[np.datetime64]
-AR_LIKE_O: List[np.object_]
+AR_LIKE_b: list[bool]
+AR_LIKE_u: list[np.uint32]
+AR_LIKE_i: list[int]
+AR_LIKE_f: list[float]
+AR_LIKE_c: list[complex]
+AR_LIKE_m: list[np.timedelta64]
+AR_LIKE_M: list[np.datetime64]
+AR_LIKE_O: list[np.object_]
# Array subtraction
diff --git a/numpy/typing/tests/data/reveal/array_constructors.pyi b/numpy/typing/tests/data/reveal/array_constructors.pyi
index 399564e66..c3b0c3457 100644
--- a/numpy/typing/tests/data/reveal/array_constructors.pyi
+++ b/numpy/typing/tests/data/reveal/array_constructors.pyi
@@ -1,4 +1,4 @@
-from typing import List, Any, TypeVar
+from typing import Any, TypeVar
from pathlib import Path
import numpy as np
@@ -12,7 +12,7 @@ i8: np.int64
A: npt.NDArray[np.float64]
B: SubClass[np.float64]
-C: List[int]
+C: list[int]
def func(i: int, j: int, **kwargs: Any) -> SubClass[np.float64]: ...
diff --git a/numpy/typing/tests/data/reveal/arraypad.pyi b/numpy/typing/tests/data/reveal/arraypad.pyi
index 995f82b57..a05d44034 100644
--- a/numpy/typing/tests/data/reveal/arraypad.pyi
+++ b/numpy/typing/tests/data/reveal/arraypad.pyi
@@ -1,18 +1,19 @@
-from typing import List, Any, Mapping, Tuple, SupportsIndex
+from collections.abc import Mapping
+from typing import Any, SupportsIndex
import numpy as np
import numpy.typing as npt
def mode_func(
ar: npt.NDArray[np.number[Any]],
- width: Tuple[int, int],
+ width: tuple[int, int],
iaxis: SupportsIndex,
kwargs: Mapping[str, Any],
) -> None: ...
AR_i8: npt.NDArray[np.int64]
AR_f8: npt.NDArray[np.float64]
-AR_LIKE: List[int]
+AR_LIKE: list[int]
reveal_type(np.pad(AR_i8, (2, 3), "constant")) # E: ndarray[Any, dtype[{int64}]]
reveal_type(np.pad(AR_LIKE, (2, 3), "constant")) # E: ndarray[Any, dtype[Any]]
diff --git a/numpy/typing/tests/data/reveal/einsumfunc.pyi b/numpy/typing/tests/data/reveal/einsumfunc.pyi
index 5b07e6d3c..3c7146ada 100644
--- a/numpy/typing/tests/data/reveal/einsumfunc.pyi
+++ b/numpy/typing/tests/data/reveal/einsumfunc.pyi
@@ -1,12 +1,12 @@
-from typing import List, Any
+from typing import Any
import numpy as np
-AR_LIKE_b: List[bool]
-AR_LIKE_u: List[np.uint32]
-AR_LIKE_i: List[int]
-AR_LIKE_f: List[float]
-AR_LIKE_c: List[complex]
-AR_LIKE_U: List[str]
+AR_LIKE_b: list[bool]
+AR_LIKE_u: list[np.uint32]
+AR_LIKE_i: list[int]
+AR_LIKE_f: list[float]
+AR_LIKE_c: list[complex]
+AR_LIKE_U: list[str]
OUT_f: np.ndarray[Any, np.dtype[np.float64]]
diff --git a/numpy/typing/tests/data/reveal/index_tricks.pyi b/numpy/typing/tests/data/reveal/index_tricks.pyi
index cee4d8c3e..365a8ee51 100644
--- a/numpy/typing/tests/data/reveal/index_tricks.pyi
+++ b/numpy/typing/tests/data/reveal/index_tricks.pyi
@@ -1,10 +1,10 @@
-from typing import Any, List
+from typing import Any
import numpy as np
-AR_LIKE_b: List[bool]
-AR_LIKE_i: List[int]
-AR_LIKE_f: List[float]
-AR_LIKE_U: List[str]
+AR_LIKE_b: list[bool]
+AR_LIKE_i: list[int]
+AR_LIKE_f: list[float]
+AR_LIKE_U: list[str]
AR_i8: np.ndarray[Any, np.dtype[np.int64]]
diff --git a/numpy/typing/tests/data/reveal/lib_utils.pyi b/numpy/typing/tests/data/reveal/lib_utils.pyi
index d82012707..9b1bf4123 100644
--- a/numpy/typing/tests/data/reveal/lib_utils.pyi
+++ b/numpy/typing/tests/data/reveal/lib_utils.pyi
@@ -1,10 +1,10 @@
from io import StringIO
-from typing import Any, Dict
+from typing import Any
import numpy as np
AR: np.ndarray[Any, np.dtype[np.float64]]
-AR_DICT: Dict[str, np.ndarray[Any, np.dtype[np.float64]]]
+AR_DICT: dict[str, np.ndarray[Any, np.dtype[np.float64]]]
FILE: StringIO
def func(a: int) -> bool: ...
diff --git a/numpy/typing/tests/data/reveal/multiarray.pyi b/numpy/typing/tests/data/reveal/multiarray.pyi
index 0e91a7afd..cbe30c520 100644
--- a/numpy/typing/tests/data/reveal/multiarray.pyi
+++ b/numpy/typing/tests/data/reveal/multiarray.pyi
@@ -1,4 +1,4 @@
-from typing import Any, List, TypeVar
+from typing import Any, TypeVar
from pathlib import Path
import numpy as np
@@ -16,8 +16,8 @@ AR_u1: npt.NDArray[np.uint8]
AR_m: npt.NDArray[np.timedelta64]
AR_M: npt.NDArray[np.datetime64]
-AR_LIKE_f: List[float]
-AR_LIKE_i: List[int]
+AR_LIKE_f: list[float]
+AR_LIKE_i: list[int]
m: np.timedelta64
M: np.datetime64
diff --git a/numpy/typing/tests/data/reveal/nested_sequence.pyi b/numpy/typing/tests/data/reveal/nested_sequence.pyi
index 4d3aad467..771bd54bb 100644
--- a/numpy/typing/tests/data/reveal/nested_sequence.pyi
+++ b/numpy/typing/tests/data/reveal/nested_sequence.pyi
@@ -1,4 +1,4 @@
-from typing import Sequence, Tuple, List, Any
+from typing import Sequence, Any
import numpy.typing as npt
a: Sequence[int]
@@ -6,8 +6,8 @@ b: Sequence[Sequence[int]]
c: Sequence[Sequence[Sequence[int]]]
d: Sequence[Sequence[Sequence[Sequence[int]]]]
e: Sequence[bool]
-f: Tuple[int, ...]
-g: List[int]
+f: tuple[int, ...]
+g: list[int]
h: Sequence[Any]
def func(a: npt._NestedSequence[int]) -> None:
diff --git a/numpy/typing/tests/data/reveal/npyio.pyi b/numpy/typing/tests/data/reveal/npyio.pyi
index ef5d35913..68605cf94 100644
--- a/numpy/typing/tests/data/reveal/npyio.pyi
+++ b/numpy/typing/tests/data/reveal/npyio.pyi
@@ -1,6 +1,6 @@
import re
import pathlib
-from typing import IO, List
+from typing import IO
import numpy.typing as npt
import numpy as np
@@ -14,7 +14,7 @@ bag_obj: np.lib.npyio.BagObj[int]
npz_file: np.lib.npyio.NpzFile
AR_i8: npt.NDArray[np.int64]
-AR_LIKE_f8: List[float]
+AR_LIKE_f8: list[float]
class BytesWriter:
def write(self, data: bytes) -> None: ...
diff --git a/numpy/typing/tests/data/reveal/numeric.pyi b/numpy/typing/tests/data/reveal/numeric.pyi
index bf5653937..246d79be8 100644
--- a/numpy/typing/tests/data/reveal/numeric.pyi
+++ b/numpy/typing/tests/data/reveal/numeric.pyi
@@ -5,7 +5,6 @@ Does not include tests which fall under ``array_constructors``.
"""
-from typing import List
import numpy as np
import numpy.typing as npt
@@ -22,7 +21,7 @@ AR_c16: npt.NDArray[np.complex128]
AR_m: npt.NDArray[np.timedelta64]
AR_O: npt.NDArray[np.object_]
-B: List[int]
+B: list[int]
C: SubClass
reveal_type(np.count_nonzero(i8)) # E: int
diff --git a/numpy/typing/tests/data/reveal/random.pyi b/numpy/typing/tests/data/reveal/random.pyi
index 4e06aa7d5..edea6a291 100644
--- a/numpy/typing/tests/data/reveal/random.pyi
+++ b/numpy/typing/tests/data/reveal/random.pyi
@@ -1,6 +1,6 @@
from __future__ import annotations
-from typing import Any, List
+from typing import Any
import numpy as np
@@ -79,13 +79,13 @@ D_arr_0p9: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.9])
D_arr_1p5: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.5])
I_arr_10: np.ndarray[Any, np.dtype[np.int_]] = np.array([10], dtype=np.int_)
I_arr_20: np.ndarray[Any, np.dtype[np.int_]] = np.array([20], dtype=np.int_)
-D_arr_like_0p1: List[float] = [0.1]
-D_arr_like_0p5: List[float] = [0.5]
-D_arr_like_0p9: List[float] = [0.9]
-D_arr_like_1p5: List[float] = [1.5]
-I_arr_like_10: List[int] = [10]
-I_arr_like_20: List[int] = [20]
-D_2D_like: List[List[float]] = [[1, 2], [2, 3], [3, 4], [4, 5.1]]
+D_arr_like_0p1: list[float] = [0.1]
+D_arr_like_0p5: list[float] = [0.5]
+D_arr_like_0p9: list[float] = [0.9]
+D_arr_like_1p5: list[float] = [1.5]
+I_arr_like_10: list[int] = [10]
+I_arr_like_20: list[int] = [20]
+D_2D_like: list[list[float]] = [[1, 2], [2, 3], [3, 4], [4, 5.1]]
D_2D: np.ndarray[Any, np.dtype[np.float64]] = np.array(D_2D_like)
S_out: np.ndarray[Any, np.dtype[np.float32]] = np.empty(1, dtype=np.float32)
D_out: np.ndarray[Any, np.dtype[np.float64]] = np.empty(1)
@@ -501,7 +501,7 @@ reveal_type(def_gen.integers([100])) # E: ndarray[Any, dtype[signedinteger[typi
reveal_type(def_gen.integers(0, [100])) # E: ndarray[Any, dtype[signedinteger[typing._64Bit]]]
I_bool_low: np.ndarray[Any, np.dtype[np.bool_]] = np.array([0], dtype=np.bool_)
-I_bool_low_like: List[int] = [0]
+I_bool_low_like: list[int] = [0]
I_bool_high_open: np.ndarray[Any, np.dtype[np.bool_]] = np.array([1], dtype=np.bool_)
I_bool_high_closed: np.ndarray[Any, np.dtype[np.bool_]] = np.array([1], dtype=np.bool_)
@@ -530,7 +530,7 @@ reveal_type(def_gen.integers(I_bool_low, I_bool_high_closed, dtype=np.bool_, end
reveal_type(def_gen.integers(0, I_bool_high_closed, dtype=np.bool_, endpoint=True)) # E: ndarray[Any, dtype[bool_]
I_u1_low: np.ndarray[Any, np.dtype[np.uint8]] = np.array([0], dtype=np.uint8)
-I_u1_low_like: List[int] = [0]
+I_u1_low_like: list[int] = [0]
I_u1_high_open: np.ndarray[Any, np.dtype[np.uint8]] = np.array([255], dtype=np.uint8)
I_u1_high_closed: np.ndarray[Any, np.dtype[np.uint8]] = np.array([255], dtype=np.uint8)
@@ -571,7 +571,7 @@ reveal_type(def_gen.integers(I_u1_low, I_u1_high_closed, dtype=np.uint8, endpoin
reveal_type(def_gen.integers(0, I_u1_high_closed, dtype=np.uint8, endpoint=True)) # E: ndarray[Any, dtype[unsignedinteger[typing._8Bit]]]
I_u2_low: np.ndarray[Any, np.dtype[np.uint16]] = np.array([0], dtype=np.uint16)
-I_u2_low_like: List[int] = [0]
+I_u2_low_like: list[int] = [0]
I_u2_high_open: np.ndarray[Any, np.dtype[np.uint16]] = np.array([65535], dtype=np.uint16)
I_u2_high_closed: np.ndarray[Any, np.dtype[np.uint16]] = np.array([65535], dtype=np.uint16)
@@ -612,7 +612,7 @@ reveal_type(def_gen.integers(I_u2_low, I_u2_high_closed, dtype=np.uint16, endpoi
reveal_type(def_gen.integers(0, I_u2_high_closed, dtype=np.uint16, endpoint=True)) # E: ndarray[Any, dtype[unsignedinteger[typing._16Bit]]]
I_u4_low: np.ndarray[Any, np.dtype[np.uint32]] = np.array([0], dtype=np.uint32)
-I_u4_low_like: List[int] = [0]
+I_u4_low_like: list[int] = [0]
I_u4_high_open: np.ndarray[Any, np.dtype[np.uint32]] = np.array([4294967295], dtype=np.uint32)
I_u4_high_closed: np.ndarray[Any, np.dtype[np.uint32]] = np.array([4294967295], dtype=np.uint32)
@@ -678,7 +678,7 @@ reveal_type(def_gen.integers(I_u4_low, I_u4_high_closed, dtype=np.uint, endpoint
reveal_type(def_gen.integers(0, I_u4_high_closed, dtype=np.uint, endpoint=True)) # E: ndarray[Any, dtype[{uint}]]
I_u8_low: np.ndarray[Any, np.dtype[np.uint64]] = np.array([0], dtype=np.uint64)
-I_u8_low_like: List[int] = [0]
+I_u8_low_like: list[int] = [0]
I_u8_high_open: np.ndarray[Any, np.dtype[np.uint64]] = np.array([18446744073709551615], dtype=np.uint64)
I_u8_high_closed: np.ndarray[Any, np.dtype[np.uint64]] = np.array([18446744073709551615], dtype=np.uint64)
@@ -719,7 +719,7 @@ reveal_type(def_gen.integers(I_u8_low, I_u8_high_closed, dtype=np.uint64, endpoi
reveal_type(def_gen.integers(0, I_u8_high_closed, dtype=np.uint64, endpoint=True)) # E: ndarray[Any, dtype[unsignedinteger[typing._64Bit]]]
I_i1_low: np.ndarray[Any, np.dtype[np.int8]] = np.array([-128], dtype=np.int8)
-I_i1_low_like: List[int] = [-128]
+I_i1_low_like: list[int] = [-128]
I_i1_high_open: np.ndarray[Any, np.dtype[np.int8]] = np.array([127], dtype=np.int8)
I_i1_high_closed: np.ndarray[Any, np.dtype[np.int8]] = np.array([127], dtype=np.int8)
@@ -760,7 +760,7 @@ reveal_type(def_gen.integers(I_i1_low, I_i1_high_closed, dtype=np.int8, endpoint
reveal_type(def_gen.integers(-128, I_i1_high_closed, dtype=np.int8, endpoint=True)) # E: ndarray[Any, dtype[signedinteger[typing._8Bit]]]
I_i2_low: np.ndarray[Any, np.dtype[np.int16]] = np.array([-32768], dtype=np.int16)
-I_i2_low_like: List[int] = [-32768]
+I_i2_low_like: list[int] = [-32768]
I_i2_high_open: np.ndarray[Any, np.dtype[np.int16]] = np.array([32767], dtype=np.int16)
I_i2_high_closed: np.ndarray[Any, np.dtype[np.int16]] = np.array([32767], dtype=np.int16)
@@ -801,7 +801,7 @@ reveal_type(def_gen.integers(I_i2_low, I_i2_high_closed, dtype=np.int16, endpoin
reveal_type(def_gen.integers(-32768, I_i2_high_closed, dtype=np.int16, endpoint=True)) # E: ndarray[Any, dtype[signedinteger[typing._16Bit]]]
I_i4_low: np.ndarray[Any, np.dtype[np.int32]] = np.array([-2147483648], dtype=np.int32)
-I_i4_low_like: List[int] = [-2147483648]
+I_i4_low_like: list[int] = [-2147483648]
I_i4_high_open: np.ndarray[Any, np.dtype[np.int32]] = np.array([2147483647], dtype=np.int32)
I_i4_high_closed: np.ndarray[Any, np.dtype[np.int32]] = np.array([2147483647], dtype=np.int32)
@@ -842,7 +842,7 @@ reveal_type(def_gen.integers(I_i4_low, I_i4_high_closed, dtype=np.int32, endpoin
reveal_type(def_gen.integers(-2147483648, I_i4_high_closed, dtype=np.int32, endpoint=True)) # E: ndarray[Any, dtype[signedinteger[typing._32Bit]]]
I_i8_low: np.ndarray[Any, np.dtype[np.int64]] = np.array([-9223372036854775808], dtype=np.int64)
-I_i8_low_like: List[int] = [-9223372036854775808]
+I_i8_low_like: list[int] = [-9223372036854775808]
I_i8_high_open: np.ndarray[Any, np.dtype[np.int64]] = np.array([9223372036854775807], dtype=np.int64)
I_i8_high_closed: np.ndarray[Any, np.dtype[np.int64]] = np.array([9223372036854775807], dtype=np.int64)
diff --git a/numpy/typing/tests/data/reveal/rec.pyi b/numpy/typing/tests/data/reveal/rec.pyi
index 9921621f1..b2eaca899 100644
--- a/numpy/typing/tests/data/reveal/rec.pyi
+++ b/numpy/typing/tests/data/reveal/rec.pyi
@@ -1,12 +1,12 @@
import io
-from typing import Any, List
+from typing import Any
import numpy as np
import numpy.typing as npt
AR_i8: npt.NDArray[np.int64]
REC_AR_V: np.recarray[Any, np.dtype[np.record]]
-AR_LIST: List[npt.NDArray[np.int64]]
+AR_LIST: list[npt.NDArray[np.int64]]
format_parser: np.format_parser
record: np.record
diff --git a/numpy/typing/tests/data/reveal/shape_base.pyi b/numpy/typing/tests/data/reveal/shape_base.pyi
index f13678c3a..70e85dd09 100644
--- a/numpy/typing/tests/data/reveal/shape_base.pyi
+++ b/numpy/typing/tests/data/reveal/shape_base.pyi
@@ -1,6 +1,6 @@
import numpy as np
from numpy.typing import NDArray
-from typing import Any, List
+from typing import Any
i8: np.int64
f8: np.float64
@@ -9,7 +9,7 @@ AR_b: NDArray[np.bool_]
AR_i8: NDArray[np.int64]
AR_f8: NDArray[np.float64]
-AR_LIKE_f8: List[float]
+AR_LIKE_f8: list[float]
reveal_type(np.take_along_axis(AR_f8, AR_i8, axis=1)) # E: ndarray[Any, dtype[{float64}]]
reveal_type(np.take_along_axis(f8, AR_i8, axis=None)) # E: ndarray[Any, dtype[{float64}]]
diff --git a/numpy/typing/tests/data/reveal/stride_tricks.pyi b/numpy/typing/tests/data/reveal/stride_tricks.pyi
index 0d6dcd388..4eeb42095 100644
--- a/numpy/typing/tests/data/reveal/stride_tricks.pyi
+++ b/numpy/typing/tests/data/reveal/stride_tricks.pyi
@@ -1,10 +1,10 @@
-from typing import List, Dict, Any
+from typing import Any
import numpy as np
import numpy.typing as npt
AR_f8: npt.NDArray[np.float64]
-AR_LIKE_f: List[float]
-interface_dict: Dict[str, Any]
+AR_LIKE_f: list[float]
+interface_dict: dict[str, Any]
reveal_type(np.lib.stride_tricks.DummyArray(interface_dict)) # E: lib.stride_tricks.DummyArray
diff --git a/numpy/typing/tests/data/reveal/twodim_base.pyi b/numpy/typing/tests/data/reveal/twodim_base.pyi
index 0318c3cf1..0dc58d437 100644
--- a/numpy/typing/tests/data/reveal/twodim_base.pyi
+++ b/numpy/typing/tests/data/reveal/twodim_base.pyi
@@ -1,4 +1,4 @@
-from typing import Any, List, TypeVar
+from typing import Any, TypeVar
import numpy as np
import numpy.typing as npt
@@ -21,7 +21,7 @@ AR_f: npt.NDArray[np.float64]
AR_c: npt.NDArray[np.complex128]
AR_O: npt.NDArray[np.object_]
-AR_LIKE_b: List[bool]
+AR_LIKE_b: list[bool]
reveal_type(np.fliplr(AR_b)) # E: ndarray[Any, dtype[bool_]]
reveal_type(np.fliplr(AR_LIKE_b)) # E: ndarray[Any, dtype[Any]]
diff --git a/numpy/typing/tests/data/reveal/type_check.pyi b/numpy/typing/tests/data/reveal/type_check.pyi
index 13d41d844..40344905b 100644
--- a/numpy/typing/tests/data/reveal/type_check.pyi
+++ b/numpy/typing/tests/data/reveal/type_check.pyi
@@ -1,4 +1,3 @@
-from typing import List
import numpy as np
import numpy.typing as npt
@@ -14,7 +13,7 @@ AR_f16: npt.NDArray[np.floating[npt._128Bit]]
AR_c8: npt.NDArray[np.complex64]
AR_c16: npt.NDArray[np.complex128]
-AR_LIKE_f: List[float]
+AR_LIKE_f: list[float]
class RealObj:
real: slice
diff --git a/numpy/typing/tests/data/reveal/ufunclike.pyi b/numpy/typing/tests/data/reveal/ufunclike.pyi
index 2d67c923f..9f06600b6 100644
--- a/numpy/typing/tests/data/reveal/ufunclike.pyi
+++ b/numpy/typing/tests/data/reveal/ufunclike.pyi
@@ -1,11 +1,11 @@
-from typing import List, Any
+from typing import Any
import numpy as np
-AR_LIKE_b: List[bool]
-AR_LIKE_u: List[np.uint32]
-AR_LIKE_i: List[int]
-AR_LIKE_f: List[float]
-AR_LIKE_O: List[np.object_]
+AR_LIKE_b: list[bool]
+AR_LIKE_u: list[np.uint32]
+AR_LIKE_i: list[int]
+AR_LIKE_f: list[float]
+AR_LIKE_O: list[np.object_]
AR_U: np.ndarray[Any, np.dtype[np.str_]]
diff --git a/numpy/typing/tests/data/reveal/warnings_and_errors.pyi b/numpy/typing/tests/data/reveal/warnings_and_errors.pyi
index d5c50448a..19fa432f9 100644
--- a/numpy/typing/tests/data/reveal/warnings_and_errors.pyi
+++ b/numpy/typing/tests/data/reveal/warnings_and_errors.pyi
@@ -1,5 +1,3 @@
-from typing import Type
-
import numpy as np
reveal_type(np.ModuleDeprecationWarning()) # E: ModuleDeprecationWarning
diff --git a/numpy/typing/tests/test_generic_alias.py b/numpy/typing/tests/test_generic_alias.py
index 39343420b..af6eb8b36 100644
--- a/numpy/typing/tests/test_generic_alias.py
+++ b/numpy/typing/tests/test_generic_alias.py
@@ -5,7 +5,8 @@ import copy
import types
import pickle
import weakref
-from typing import TypeVar, Any, Callable, Tuple, Type, Union
+from collections.abc import Callable
+from typing import TypeVar, Any, Union
import pytest
import numpy as np
@@ -31,7 +32,7 @@ GETATTR_NAMES = sorted(set(dir(np.ndarray)) - _GenericAlias._ATTR_EXCEPTIONS)
BUFFER = np.array([1], dtype=np.int64)
BUFFER.setflags(write=False)
-def _get_subclass_mro(base: type) -> Tuple[type, ...]:
+def _get_subclass_mro(base: type) -> tuple[type, ...]:
class Subclass(base): # type: ignore[misc,valid-type]
pass
return Subclass.__mro__[1:]
@@ -132,7 +133,7 @@ class TestGenericAlias:
def test_raise(
self,
name: str,
- exc_type: Type[BaseException],
+ exc_type: type[BaseException],
func: FuncType,
) -> None:
"""Test operations that are supposed to raise."""