@@ -851,10 +851,6 @@ type _BuiltinObjectLike = (
851851 | tuple [Any , ...] | list [Any ] | set [Any ] | frozenset [Any ] | dict [Any , Any ]
852852) # fmt: skip
853853
854- # Introduce an alias for `dtype` to avoid naming conflicts.
855- # NOTE: This should _not_ be `Final[_]`, `_: TypeAlias`, or `type _`
856- _dtype = dtype
857-
858854type _ByteOrderChar = L ["<" , ">" , "=" , "|" ]
859855# can be anything, is case-insensitive, and only the first character matters
860856type _ByteOrder = L [
@@ -1717,6 +1713,10 @@ class dtype(Generic[_ScalarT_co], metaclass=_DTypeMeta):
17171713 @property
17181714 def type (self ) -> py_type [_ScalarT_co ]: ...
17191715
1716+ # Introduce an alias for `dtype` to avoid naming conflicts.
1717+ # NOTE: This should _not_ be `Final[_]`, `_: TypeAlias`, or `type _`
1718+ _dtype = dtype
1719+
17201720@type_check_only
17211721class _ArrayOrScalarCommon :
17221722 @property
@@ -2358,7 +2358,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
23582358 out : None = None ,
23592359 * ,
23602360 keepdims : L [True ],
2361- ) -> ndarray [_ShapeT_co , dtype [intp ]]: ...
2361+ ) -> ndarray [_ShapeT_co , _dtype [intp ]]: ...
23622362 @overload # out: <given> (keyword)
23632363 def argmax [ArrayT : NDArray [intp ]](
23642364 self ,
@@ -2401,7 +2401,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
24012401 out : None = None ,
24022402 * ,
24032403 keepdims : L [True ],
2404- ) -> ndarray [_ShapeT_co , dtype [intp ]]: ...
2404+ ) -> ndarray [_ShapeT_co , _dtype [intp ]]: ...
24052405 @overload # out: <given> (keyword)
24062406 def argmin [ArrayT : NDArray [intp ]](
24072407 self ,
@@ -2447,7 +2447,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
24472447 * ,
24482448 keepdims : L [True ],
24492449 where : _ArrayLikeBool_co = True ,
2450- ) -> ndarray [_ShapeT_co , dtype [bool_ ]]: ...
2450+ ) -> ndarray [_ShapeT_co , _dtype [bool_ ]]: ...
24512451 @overload # out: <given> (keyword)
24522452 def all [ArrayT : ndarray ](
24532453 self ,
@@ -2494,7 +2494,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
24942494 * ,
24952495 keepdims : L [True ],
24962496 where : _ArrayLikeBool_co = True ,
2497- ) -> ndarray [_ShapeT_co , dtype [bool_ ]]: ...
2497+ ) -> ndarray [_ShapeT_co , _dtype [bool_ ]]: ...
24982498 @overload # out: <given> (keyword)
24992499 def any [ArrayT : ndarray ](
25002500 self ,
@@ -2581,7 +2581,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
25812581 keepdims : L [True ],
25822582 initial : _IntLike_co | _NoValueType = ...,
25832583 where : _ArrayLikeBool_co | _NoValueType = ...,
2584- ) -> ndarray [_ShapeT_co , dtype [int_ ]]: ...
2584+ ) -> ndarray [_ShapeT_co , _dtype [int_ ]]: ...
25852585 @overload # object_
25862586 def prod (
25872587 self : NDArray [object_ ],
@@ -2614,7 +2614,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
26142614 keepdims : L [True ],
26152615 initial : _NumberLike_co | _NoValueType = ...,
26162616 where : _ArrayLikeBool_co | _NoValueType = ...,
2617- ) -> ndarray [_ShapeT_co , dtype [ScalarT ]]: ...
2617+ ) -> ndarray [_ShapeT_co , _dtype [ScalarT ]]: ...
26182618 @overload # dtype: ScalarT (positional), keepdims=True
26192619 def prod [ScalarT : generic ](
26202620 self : NDArray [number | bool_ | object_ ],
@@ -2625,7 +2625,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
26252625 keepdims : L [True ],
26262626 initial : _NumberLike_co | _NoValueType = ...,
26272627 where : _ArrayLikeBool_co | _NoValueType = ...,
2628- ) -> ndarray [_ShapeT_co , dtype [ScalarT ]]: ...
2628+ ) -> ndarray [_ShapeT_co , _dtype [ScalarT ]]: ...
26292629 @overload # axis: <given>, dtype: ScalarT
26302630 def prod [ScalarT : generic ](
26312631 self : NDArray [number | bool_ | object_ ],
@@ -2760,7 +2760,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
27602760 keepdims : L [True ],
27612761 initial : _IntLike_co | _NoValueType = ...,
27622762 where : _ArrayLikeBool_co | _NoValueType = ...,
2763- ) -> ndarray [_ShapeT_co , dtype [int_ ]]: ...
2763+ ) -> ndarray [_ShapeT_co , _dtype [int_ ]]: ...
27642764 @overload # object_
27652765 def sum (
27662766 self : NDArray [object_ ],
@@ -2793,7 +2793,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
27932793 keepdims : L [True ],
27942794 initial : _NumberLike_co | _NoValueType = ...,
27952795 where : _ArrayLikeBool_co | _NoValueType = ...,
2796- ) -> ndarray [_ShapeT_co , dtype [ScalarT ]]: ...
2796+ ) -> ndarray [_ShapeT_co , _dtype [ScalarT ]]: ...
27972797 @overload # dtype: ScalarT (positional), keepdims=True
27982798 def sum [ScalarT : generic ](
27992799 self : NDArray [number | bool_ | timedelta64 | object_ ],
@@ -2804,7 +2804,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
28042804 keepdims : L [True ],
28052805 initial : _NumberLike_co | _NoValueType = ...,
28062806 where : _ArrayLikeBool_co | _NoValueType = ...,
2807- ) -> ndarray [_ShapeT_co , dtype [ScalarT ]]: ...
2807+ ) -> ndarray [_ShapeT_co , _dtype [ScalarT ]]: ...
28082808 @overload # axis: <given>, dtype: ScalarT
28092809 def sum [ScalarT : generic ](
28102810 self : NDArray [number | bool_ | timedelta64 | object_ ],
@@ -2875,7 +2875,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
28752875 # keep in sync with `MaskedArray.cumprod`
28762876 @override # type: ignore[override]
28772877 @overload # inexact | object_
2878- def cumprod [DTypeT : dtype [inexact | object_ ]](
2878+ def cumprod [DTypeT : _dtype [inexact | object_ ]](
28792879 self : ndarray [Any , DTypeT ],
28802880 axis : None = None ,
28812881 dtype : None = None ,
@@ -2887,15 +2887,15 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
28872887 axis : None = None ,
28882888 dtype : None = None ,
28892889 out : None = None ,
2890- ) -> ndarray [_1D , dtype [int_ ]]: ...
2890+ ) -> ndarray [_1D , _dtype [int_ ]]: ...
28912891 @overload # dtype: <known> (keyword)
28922892 def cumprod [ScalarT : generic ](
28932893 self : NDArray [number | bool_ | object_ ],
28942894 axis : None = None ,
28952895 * ,
28962896 dtype : _DTypeLike [ScalarT ],
28972897 out : None = None ,
2898- ) -> ndarray [_1D , dtype [ScalarT ]]: ...
2898+ ) -> ndarray [_1D , _dtype [ScalarT ]]: ...
28992899 @overload # dtype: <unknown> (keyword)
29002900 def cumprod (
29012901 self : NDArray [number | bool_ | object_ ],
@@ -2910,7 +2910,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
29102910 axis : None ,
29112911 dtype : _DTypeLike [ScalarT ],
29122912 out : None = None ,
2913- ) -> ndarray [_1D , dtype [ScalarT ]]: ...
2913+ ) -> ndarray [_1D , _dtype [ScalarT ]]: ...
29142914 @overload # dtype: <unknown> (positional)
29152915 def cumprod (
29162916 self : NDArray [number | bool_ | object_ ],
@@ -2927,21 +2927,21 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
29272927 ) -> ArrayT : ...
29282928 @overload # +integer, axis: <given>
29292929 def cumprod [ShapeT : _Shape ](
2930- self : ndarray [ShapeT , dtype [integer | bool_ ]],
2930+ self : ndarray [ShapeT , _dtype [integer | bool_ ]],
29312931 axis : SupportsIndex ,
29322932 dtype : None = None ,
29332933 out : None = None ,
2934- ) -> ndarray [ShapeT , dtype [int_ ]]: ...
2934+ ) -> ndarray [ShapeT , _dtype [int_ ]]: ...
29352935 @overload # axis: <given>, dtype: <known>
29362936 def cumprod [ShapeT : _Shape , ScalarT : generic ](
2937- self : ndarray [ShapeT , dtype [number | bool_ | object_ ]],
2937+ self : ndarray [ShapeT , _dtype [number | bool_ | object_ ]],
29382938 axis : SupportsIndex ,
29392939 dtype : _DTypeLike [ScalarT ],
29402940 out : None = None ,
2941- ) -> ndarray [ShapeT , dtype [ScalarT ]]: ...
2941+ ) -> ndarray [ShapeT , _dtype [ScalarT ]]: ...
29422942 @overload # axis: <given>, dtype: <unknown>
29432943 def cumprod [ShapeT : _Shape ](
2944- self : ndarray [ShapeT , dtype [number | bool_ | object_ ]],
2944+ self : ndarray [ShapeT , _dtype [number | bool_ | object_ ]],
29452945 axis : SupportsIndex ,
29462946 dtype : DTypeLike ,
29472947 out : None = None ,
@@ -2965,7 +2965,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
29652965 # keep in sync with `MaskedArray.cumsum`
29662966 @override # type: ignore[override]
29672967 @overload # inexact | timedelta64 | object_
2968- def cumsum [DTypeT : dtype [inexact | timedelta64 | object_ ]](
2968+ def cumsum [DTypeT : _dtype [inexact | timedelta64 | object_ ]](
29692969 self : ndarray [Any , DTypeT ],
29702970 axis : None = None ,
29712971 dtype : None = None ,
@@ -2977,15 +2977,15 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
29772977 axis : None = None ,
29782978 dtype : None = None ,
29792979 out : None = None ,
2980- ) -> ndarray [_1D , dtype [int_ ]]: ...
2980+ ) -> ndarray [_1D , _dtype [int_ ]]: ...
29812981 @overload # dtype: <known> (keyword)
29822982 def cumsum [ScalarT : generic ](
29832983 self : NDArray [number | bool_ | timedelta64 | object_ ],
29842984 axis : None = None ,
29852985 * ,
29862986 dtype : _DTypeLike [ScalarT ],
29872987 out : None = None ,
2988- ) -> ndarray [_1D , dtype [ScalarT ]]: ...
2988+ ) -> ndarray [_1D , _dtype [ScalarT ]]: ...
29892989 @overload # dtype: <unknown> (keyword)
29902990 def cumsum (
29912991 self : NDArray [number | bool_ | timedelta64 | object_ ],
@@ -3000,7 +3000,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
30003000 axis : None ,
30013001 dtype : _DTypeLike [ScalarT ],
30023002 out : None = None ,
3003- ) -> ndarray [_1D , dtype [ScalarT ]]: ...
3003+ ) -> ndarray [_1D , _dtype [ScalarT ]]: ...
30043004 @overload # dtype: <unknown> (positional)
30053005 def cumsum (
30063006 self : NDArray [number | bool_ | timedelta64 | object_ ],
@@ -3017,21 +3017,21 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
30173017 ) -> ArrayT : ...
30183018 @overload # +integer, axis: <given>
30193019 def cumsum [ShapeT : _Shape ](
3020- self : ndarray [ShapeT , dtype [integer | bool_ ]],
3020+ self : ndarray [ShapeT , _dtype [integer | bool_ ]],
30213021 axis : SupportsIndex ,
30223022 dtype : None = None ,
30233023 out : None = None ,
3024- ) -> ndarray [ShapeT , dtype [int_ ]]: ...
3024+ ) -> ndarray [ShapeT , _dtype [int_ ]]: ...
30253025 @overload # axis: <given>, dtype: <known>
30263026 def cumsum [ShapeT : _Shape , ScalarT : generic ](
3027- self : ndarray [ShapeT , dtype [number | bool_ | timedelta64 | object_ ]],
3027+ self : ndarray [ShapeT , _dtype [number | bool_ | timedelta64 | object_ ]],
30283028 axis : SupportsIndex ,
30293029 dtype : _DTypeLike [ScalarT ],
30303030 out : None = None ,
3031- ) -> ndarray [ShapeT , dtype [ScalarT ]]: ...
3031+ ) -> ndarray [ShapeT , _dtype [ScalarT ]]: ...
30323032 @overload # axis: <given>, dtype: <unknown>
30333033 def cumsum [ShapeT : _Shape ](
3034- self : ndarray [ShapeT , dtype [number | bool_ | timedelta64 | object_ ]],
3034+ self : ndarray [ShapeT , _dtype [number | bool_ | timedelta64 | object_ ]],
30353035 axis : SupportsIndex ,
30363036 dtype : DTypeLike ,
30373037 out : None = None ,
@@ -3083,7 +3083,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
30833083 * ,
30843084 keepdims : L [True ],
30853085 where : _ArrayLikeBool_co | _NoValueType = ...,
3086- ) -> ndarray [_ShapeT_co , dtype [float64 ]]: ...
3086+ ) -> ndarray [_ShapeT_co , _dtype [float64 ]]: ...
30873087 @overload # ~inexact | timedelta64
30883088 def mean [ScalarT : inexact | timedelta64 ](
30893089 self : NDArray [ScalarT ],
@@ -3133,7 +3133,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
31333133 out : None = None ,
31343134 keepdims : L [True ],
31353135 where : _ArrayLikeBool_co | _NoValueType = ...,
3136- ) -> ndarray [_ShapeT_co , dtype [ScalarT ]]: ...
3136+ ) -> ndarray [_ShapeT_co , _dtype [ScalarT ]]: ...
31373137 @overload # dtype: ScalarT (positional), keepdims=True
31383138 def mean [ScalarT : generic ](
31393139 self : NDArray [number | bool_ | timedelta64 | object_ ],
@@ -3143,7 +3143,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
31433143 * ,
31443144 keepdims : L [True ],
31453145 where : _ArrayLikeBool_co | _NoValueType = ...,
3146- ) -> ndarray [_ShapeT_co , dtype [ScalarT ]]: ...
3146+ ) -> ndarray [_ShapeT_co , _dtype [ScalarT ]]: ...
31473147 @overload # axis: <given>, dtype: ScalarT
31483148 def mean [ScalarT : generic ](
31493149 self : NDArray [number | bool_ | timedelta64 | object_ ],
@@ -3235,7 +3235,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
32353235 where : _ArrayLikeBool_co | _NoValueType = ...,
32363236 mean : _ArrayLikeNumber_co | _NoValueType = ...,
32373237 correction : float | _NoValueType = ...,
3238- ) -> ndarray [_ShapeT_co , dtype [float64 ]]: ...
3238+ ) -> ndarray [_ShapeT_co , _dtype [float64 ]]: ...
32393239 @overload # ~floating | timedelta64
32403240 def std [ScalarT : floating | timedelta64 ](
32413241 self : NDArray [ScalarT ],
@@ -3300,7 +3300,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
33003300 where : _ArrayLikeBool_co | _NoValueType = ...,
33013301 mean : _ArrayLikeNumber_co | _NoValueType = ...,
33023302 correction : float | _NoValueType = ...,
3303- ) -> ndarray [_ShapeT_co , dtype [ScalarT ]]: ...
3303+ ) -> ndarray [_ShapeT_co , _dtype [ScalarT ]]: ...
33043304 @overload # dtype: ScalarT (positional), keepdims=True
33053305 def std [ScalarT : generic ](
33063306 self : NDArray [number | bool_ | timedelta64 | object_ ],
@@ -3313,7 +3313,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
33133313 where : _ArrayLikeBool_co | _NoValueType = ...,
33143314 mean : _ArrayLikeNumber_co | _NoValueType = ...,
33153315 correction : float | _NoValueType = ...,
3316- ) -> ndarray [_ShapeT_co , dtype [ScalarT ]]: ...
3316+ ) -> ndarray [_ShapeT_co , _dtype [ScalarT ]]: ...
33173317 @overload # axis: <given>, dtype: ScalarT
33183318 def std [ScalarT : generic ](
33193319 self : NDArray [number | bool_ | timedelta64 | object_ ],
@@ -3420,7 +3420,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
34203420 where : _ArrayLikeBool_co | _NoValueType = ...,
34213421 mean : _ArrayLikeNumber_co | _NoValueType = ...,
34223422 correction : float | _NoValueType = ...,
3423- ) -> ndarray [_ShapeT_co , dtype [float64 ]]: ...
3423+ ) -> ndarray [_ShapeT_co , _dtype [float64 ]]: ...
34243424 @overload # ~floating | timedelta64
34253425 def var [ScalarT : floating | timedelta64 ](
34263426 self : NDArray [ScalarT ],
@@ -3485,7 +3485,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
34853485 where : _ArrayLikeBool_co | _NoValueType = ...,
34863486 mean : _ArrayLikeNumber_co | _NoValueType = ...,
34873487 correction : float | _NoValueType = ...,
3488- ) -> ndarray [_ShapeT_co , dtype [ScalarT ]]: ...
3488+ ) -> ndarray [_ShapeT_co , _dtype [ScalarT ]]: ...
34893489 @overload # dtype: ScalarT (positional), keepdims=True
34903490 def var [ScalarT : generic ](
34913491 self : NDArray [number | bool_ | timedelta64 | object_ ],
@@ -3498,7 +3498,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
34983498 where : _ArrayLikeBool_co | _NoValueType = ...,
34993499 mean : _ArrayLikeNumber_co | _NoValueType = ...,
35003500 correction : float | _NoValueType = ...,
3501- ) -> ndarray [_ShapeT_co , dtype [ScalarT ]]: ...
3501+ ) -> ndarray [_ShapeT_co , _dtype [ScalarT ]]: ...
35023502 @overload # axis: <given>, dtype: ScalarT
35033503 def var [ScalarT : generic ](
35043504 self : NDArray [number | bool_ | timedelta64 | object_ ],
@@ -3738,21 +3738,21 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
37383738
37393739 # keep in sync with `ma.MaskedArray.diagonal`
37403740 @overload # ?d (workaround)
3741- def diagonal [DTypeT : dtype ](
3741+ def diagonal [DTypeT : _dtype ](
37423742 self : ndarray [tuple [Never , Never , Never , Never ], DTypeT ],
37433743 offset : SupportsIndex = 0 ,
37443744 axis1 : SupportsIndex = 0 ,
37453745 axis2 : SupportsIndex = 1 ,
37463746 ) -> ndarray [_AnyShape , DTypeT ]: ...
37473747 @overload # 2d
3748- def diagonal [DTypeT : dtype ](
3748+ def diagonal [DTypeT : _dtype ](
37493749 self : ndarray [tuple [int , int ], DTypeT ],
37503750 offset : SupportsIndex = 0 ,
37513751 axis1 : SupportsIndex = 0 ,
37523752 axis2 : SupportsIndex = 1 ,
37533753 ) -> ndarray [tuple [int ], DTypeT ]: ...
37543754 @overload # 3d
3755- def diagonal [DTypeT : dtype ](
3755+ def diagonal [DTypeT : _dtype ](
37563756 self : ndarray [tuple [int , int , int ], DTypeT ],
37573757 offset : SupportsIndex = 0 ,
37583758 axis1 : SupportsIndex = 0 ,
0 commit comments