@@ -195,6 +195,7 @@ from typing import (
195
195
Final ,
196
196
final ,
197
197
ClassVar ,
198
+ TypeAlias
198
199
)
199
200
200
201
# Ensures that the stubs are picked up
@@ -641,7 +642,7 @@ def show_config() -> None: ...
641
642
642
643
_NdArraySubClass = TypeVar ("_NdArraySubClass" , bound = NDArray [Any ])
643
644
_DTypeScalar_co = TypeVar ("_DTypeScalar_co" , covariant = True , bound = generic )
644
- _ByteOrder = L ["S" , "<" , ">" , "=" , "|" , "L" , "B" , "N" , "I" , "little" , "big" , "native" ]
645
+ _ByteOrder : TypeAlias = L ["S" , "<" , ">" , "=" , "|" , "L" , "B" , "N" , "I" , "little" , "big" , "native" ]
645
646
646
647
@final
647
648
class dtype (Generic [_DTypeScalar_co ]):
@@ -894,7 +895,7 @@ class dtype(Generic[_DTypeScalar_co]):
894
895
@property
895
896
def type (self ) -> type [_DTypeScalar_co ]: ...
896
897
897
- _ArrayLikeInt = (
898
+ _ArrayLikeInt : TypeAlias = (
898
899
int
899
900
| integer [Any ]
900
901
| Sequence [int | integer [Any ]]
@@ -941,14 +942,14 @@ class flatiter(Generic[_NdArraySubClass]):
941
942
@overload
942
943
def __array__ (self , dtype : _DType , / ) -> ndarray [Any , _DType ]: ...
943
944
944
- _OrderKACF = L [None , "K" , "A" , "C" , "F" ]
945
- _OrderACF = L [None , "A" , "C" , "F" ]
946
- _OrderCF = L [None , "C" , "F" ]
945
+ _OrderKACF : TypeAlias = L [None , "K" , "A" , "C" , "F" ]
946
+ _OrderACF : TypeAlias = L [None , "A" , "C" , "F" ]
947
+ _OrderCF : TypeAlias = L [None , "C" , "F" ]
947
948
948
- _ModeKind = L ["raise" , "wrap" , "clip" ]
949
- _PartitionKind = L ["introselect" ]
950
- _SortKind = L ["quicksort" , "mergesort" , "heapsort" , "stable" ]
951
- _SortSide = L ["left" , "right" ]
949
+ _ModeKind : TypeAlias = L ["raise" , "wrap" , "clip" ]
950
+ _PartitionKind : TypeAlias = L ["introselect" ]
951
+ _SortKind : TypeAlias = L ["quicksort" , "mergesort" , "heapsort" , "stable" ]
952
+ _SortSide : TypeAlias = L ["left" , "right" ]
952
953
953
954
_ArraySelf = TypeVar ("_ArraySelf" , bound = _ArrayOrScalarCommon )
954
955
@@ -1391,7 +1392,7 @@ _NumberType = TypeVar("_NumberType", bound=number[Any])
1391
1392
if sys .version_info >= (3 , 12 ):
1392
1393
from collections .abc import Buffer as _SupportsBuffer
1393
1394
else :
1394
- _SupportsBuffer = (
1395
+ _SupportsBuffer : TypeAlias = (
1395
1396
bytes
1396
1397
| bytearray
1397
1398
| memoryview
@@ -1404,22 +1405,22 @@ else:
1404
1405
_T = TypeVar ("_T" )
1405
1406
_T_co = TypeVar ("_T_co" , covariant = True )
1406
1407
_T_contra = TypeVar ("_T_contra" , contravariant = True )
1407
- _2Tuple = tuple [_T , _T ]
1408
- _CastingKind = L ["no" , "equiv" , "safe" , "same_kind" , "unsafe" ]
1408
+ _2Tuple : TypeAlias = tuple [_T , _T ]
1409
+ _CastingKind : TypeAlias = L ["no" , "equiv" , "safe" , "same_kind" , "unsafe" ]
1409
1410
1410
- _ArrayUInt_co = NDArray [np .bool | unsignedinteger [Any ]]
1411
- _ArrayInt_co = NDArray [np .bool | integer [Any ]]
1412
- _ArrayFloat_co = NDArray [np .bool | integer [Any ] | floating [Any ]]
1413
- _ArrayComplex_co = NDArray [np .bool | integer [Any ] | floating [Any ] | complexfloating [Any , Any ]]
1414
- _ArrayNumber_co = NDArray [np .bool | number [Any ]]
1415
- _ArrayTD64_co = NDArray [np .bool | integer [Any ] | timedelta64 ]
1411
+ _ArrayUInt_co : TypeAlias = NDArray [np .bool | unsignedinteger [Any ]]
1412
+ _ArrayInt_co : TypeAlias = NDArray [np .bool | integer [Any ]]
1413
+ _ArrayFloat_co : TypeAlias = NDArray [np .bool | integer [Any ] | floating [Any ]]
1414
+ _ArrayComplex_co : TypeAlias = NDArray [np .bool | integer [Any ] | floating [Any ] | complexfloating [Any , Any ]]
1415
+ _ArrayNumber_co : TypeAlias = NDArray [np .bool | number [Any ]]
1416
+ _ArrayTD64_co : TypeAlias = NDArray [np .bool | integer [Any ] | timedelta64 ]
1416
1417
1417
1418
# Introduce an alias for `dtype` to avoid naming conflicts.
1418
- _dtype = dtype
1419
+ _dtype : TypeAlias = dtype
1419
1420
1420
1421
# `builtins.PyCapsule` unfortunately lacks annotations as of the moment;
1421
1422
# use `Any` as a stopgap measure
1422
- _PyCapsule = Any
1423
+ _PyCapsule : TypeAlias = Any
1423
1424
1424
1425
class _SupportsItem (Protocol [_T_co ]):
1425
1426
def item (self , args : Any , / ) -> _T_co : ...
@@ -2837,7 +2838,7 @@ class bool(generic):
2837
2838
__gt__ : _ComparisonOp [_NumberLike_co , _ArrayLikeNumber_co ]
2838
2839
__ge__ : _ComparisonOp [_NumberLike_co , _ArrayLikeNumber_co ]
2839
2840
2840
- bool_ = bool
2841
+ bool_ : TypeAlias = bool
2841
2842
2842
2843
class object_ (generic ):
2843
2844
def __init__ (self , value : object = ..., / ) -> None : ...
@@ -2893,9 +2894,9 @@ class datetime64(generic):
2893
2894
__gt__ : _ComparisonOp [datetime64 , _ArrayLikeDT64_co ]
2894
2895
__ge__ : _ComparisonOp [datetime64 , _ArrayLikeDT64_co ]
2895
2896
2896
- _IntValue = SupportsInt | _CharLike_co | SupportsIndex
2897
- _FloatValue = None | _CharLike_co | SupportsFloat | SupportsIndex
2898
- _ComplexValue = (
2897
+ _IntValue : TypeAlias = SupportsInt | _CharLike_co | SupportsIndex
2898
+ _FloatValue : TypeAlias = None | _CharLike_co | SupportsFloat | SupportsIndex
2899
+ _ComplexValue : TypeAlias = (
2899
2900
None
2900
2901
| _CharLike_co
2901
2902
| SupportsFloat
@@ -3049,18 +3050,18 @@ class unsignedinteger(integer[_NBit1]):
3049
3050
__divmod__ : _UnsignedIntDivMod [_NBit1 ]
3050
3051
__rdivmod__ : _UnsignedIntDivMod [_NBit1 ]
3051
3052
3052
- uint8 = unsignedinteger [_8Bit ]
3053
- uint16 = unsignedinteger [_16Bit ]
3054
- uint32 = unsignedinteger [_32Bit ]
3055
- uint64 = unsignedinteger [_64Bit ]
3053
+ uint8 : TypeAlias = unsignedinteger [_8Bit ]
3054
+ uint16 : TypeAlias = unsignedinteger [_16Bit ]
3055
+ uint32 : TypeAlias = unsignedinteger [_32Bit ]
3056
+ uint64 : TypeAlias = unsignedinteger [_64Bit ]
3056
3057
3057
- ubyte = unsignedinteger [_NBitByte ]
3058
- ushort = unsignedinteger [_NBitShort ]
3059
- uintc = unsignedinteger [_NBitIntC ]
3060
- uintp = unsignedinteger [_NBitIntP ]
3061
- uint = uintp
3062
- ulong = unsignedinteger [_NBitLong ]
3063
- ulonglong = unsignedinteger [_NBitLongLong ]
3058
+ ubyte : TypeAlias = unsignedinteger [_NBitByte ]
3059
+ ushort : TypeAlias = unsignedinteger [_NBitShort ]
3060
+ uintc : TypeAlias = unsignedinteger [_NBitIntC ]
3061
+ uintp : TypeAlias = unsignedinteger [_NBitIntP ]
3062
+ uint : TypeAlias = uintp
3063
+ ulong : TypeAlias = unsignedinteger [_NBitLong ]
3064
+ ulonglong : TypeAlias = unsignedinteger [_NBitLongLong ]
3064
3065
3065
3066
class inexact (number [_NBit1 ]): # type: ignore
3066
3067
def __getnewargs__ (self : inexact [_64Bit ]) -> tuple [float , ...]: ...
@@ -3106,14 +3107,14 @@ class floating(inexact[_NBit1]):
3106
3107
__divmod__ : _FloatDivMod [_NBit1 ]
3107
3108
__rdivmod__ : _FloatDivMod [_NBit1 ]
3108
3109
3109
- float16 = floating [_16Bit ]
3110
- float32 = floating [_32Bit ]
3111
- float64 = floating [_64Bit ]
3110
+ float16 : TypeAlias = floating [_16Bit ]
3111
+ float32 : TypeAlias = floating [_32Bit ]
3112
+ float64 : TypeAlias = floating [_64Bit ]
3112
3113
3113
- half = floating [_NBitHalf ]
3114
- single = floating [_NBitSingle ]
3115
- double = floating [_NBitDouble ]
3116
- longdouble = floating [_NBitLongDouble ]
3114
+ half : TypeAlias = floating [_NBitHalf ]
3115
+ single : TypeAlias = floating [_NBitSingle ]
3116
+ double : TypeAlias = floating [_NBitDouble ]
3117
+ longdouble : TypeAlias = floating [_NBitLongDouble ]
3117
3118
3118
3119
# The main reason for `complexfloating` having two typevars is cosmetic.
3119
3120
# It is used to clarify why `complex128`s precision is `_64Bit`, the latter
@@ -3144,12 +3145,12 @@ class complexfloating(inexact[_NBit1], Generic[_NBit1, _NBit2]):
3144
3145
__pow__ : _ComplexOp [_NBit1 ]
3145
3146
__rpow__ : _ComplexOp [_NBit1 ]
3146
3147
3147
- complex64 = complexfloating [_32Bit , _32Bit ]
3148
- complex128 = complexfloating [_64Bit , _64Bit ]
3148
+ complex64 : TypeAlias = complexfloating [_32Bit , _32Bit ]
3149
+ complex128 : TypeAlias = complexfloating [_64Bit , _64Bit ]
3149
3150
3150
- csingle = complexfloating [_NBitSingle , _NBitSingle ]
3151
- cdouble = complexfloating [_NBitDouble , _NBitDouble ]
3152
- clongdouble = complexfloating [_NBitLongDouble , _NBitLongDouble ]
3151
+ csingle : TypeAlias = complexfloating [_NBitSingle , _NBitSingle ]
3152
+ cdouble : TypeAlias = complexfloating [_NBitDouble , _NBitDouble ]
3153
+ clongdouble : TypeAlias = complexfloating [_NBitLongDouble , _NBitLongDouble ]
3153
3154
3154
3155
class flexible (generic ): ... # type: ignore
3155
3156
@@ -3528,7 +3529,7 @@ class iinfo(Generic[_IntType]):
3528
3529
@overload
3529
3530
def __new__ (cls , dtype : str ) -> iinfo [Any ]: ...
3530
3531
3531
- _NDIterFlagsKind = L [
3532
+ _NDIterFlagsKind : TypeAlias = L [
3532
3533
"buffered" ,
3533
3534
"c_index" ,
3534
3535
"copy_if_overlap" ,
@@ -3544,7 +3545,7 @@ _NDIterFlagsKind = L[
3544
3545
"zerosize_ok" ,
3545
3546
]
3546
3547
3547
- _NDIterOpFlagsKind = L [
3548
+ _NDIterOpFlagsKind : TypeAlias = L [
3548
3549
"aligned" ,
3549
3550
"allocate" ,
3550
3551
"arraymask" ,
@@ -3635,7 +3636,7 @@ class nditer:
3635
3636
@property
3636
3637
def value (self ) -> tuple [NDArray [Any ], ...]: ...
3637
3638
3638
- _MemMapModeKind = L [
3639
+ _MemMapModeKind : TypeAlias = L [
3639
3640
"readonly" , "r" ,
3640
3641
"copyonwrite" , "c" ,
3641
3642
"readwrite" , "r+" ,
0 commit comments