@@ -623,7 +623,6 @@ _AnyShapeT = TypeVar(
623
623
tuple [int , int , int , int ],
624
624
tuple [int , ...],
625
625
)
626
- _AnyItemT = TypeVar ("_AnyItemT" , bool , int , float , complex , bytes , str )
627
626
628
627
###
629
628
# Type parameters (for internal use only)
@@ -775,6 +774,7 @@ _JustFloating: TypeAlias = _nt.Just[floating]
775
774
_JustComplexFloating : TypeAlias = _nt .Just [complexfloating ]
776
775
_JustInexact : TypeAlias = _nt .Just [inexact ]
777
776
_JustNumber : TypeAlias = _nt .Just [number ]
777
+ _JustBuiltinScalar : TypeAlias = int | _nt .JustFloat | _nt .JustComplex | _nt .JustBytes | _nt .JustStr
778
778
779
779
_AbstractInexact : TypeAlias = _JustInexact | _JustFloating | _JustComplexFloating
780
780
_AbstractInteger : TypeAlias = _JustInteger | _JustSignedInteger | _JustUnsignedInteger
@@ -2141,17 +2141,21 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2141
2141
@overload
2142
2142
def __add__ (self : NDArray [_ScalarT ], x : _nt .CastsWith [_ScalarT , _ScalarOutT ], / ) -> NDArray [_ScalarOutT ]: ... # type: ignore[overload-overlap]
2143
2143
@overload
2144
+ def __add__ (self : _nt .CastsWithBuiltin [_T , _ScalarOutT ], x : _nt .SequenceND [_T ], / ) -> NDArray [_ScalarOutT ]: ...
2145
+ @overload
2146
+ def __add__ (self : _nt .CastsWithInt [_ScalarOutT ], x : _nt .SequenceND [_nt .JustInt ], / ) -> NDArray [_ScalarOutT ]: ...
2147
+ @overload
2148
+ def __add__ (self : _nt .CastsWithFloat [_ScalarOutT ], x : _nt .SequenceND [_nt .JustFloat ], / ) -> NDArray [_ScalarOutT ]: ...
2149
+ @overload
2144
2150
def __add__ (
2145
- self : NDArray [generic [_AnyItemT ]],
2146
- x : _nt .SequenceND [_AnyItemT ],
2147
- / ,
2148
- ) -> ndarray [tuple [int , ...], _DTypeT_co ]: ...
2151
+ self : _nt .CastsWithComplex [_ScalarOutT ], x : _nt .SequenceND [_nt .JustComplex ], /
2152
+ ) -> NDArray [_ScalarOutT ]: ...
2149
2153
@overload
2150
2154
def __add__ (self : NDArray [datetime64 ], x : _nt .CoTimeDelta_nd , / ) -> NDArray [datetime64 ]: ...
2151
2155
@overload
2152
2156
def __add__ (self : NDArray [_nt .co_timedelta ], x : _nt .ToDateTime_nd , / ) -> NDArray [datetime64 ]: ...
2153
2157
@overload
2154
- def __add__ (self : NDArray [object_ ], x : object , / ) -> NDArray [object_ ]: ...
2158
+ def __add__ (self : NDArray [object_ ], x : object , / ) -> NDArray [object_ ]: ... # type: ignore[overload-cannot-match]
2155
2159
@overload
2156
2160
def __add__ (self : NDArray [str_ ], x : _nt .ToString_nd [_T ], / ) -> _nt .StringArrayND [_T ]: ...
2157
2161
@overload
@@ -2163,17 +2167,23 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2163
2167
@overload
2164
2168
def __radd__ (self : NDArray [_ScalarT ], x : _nt .CastsWith [_ScalarT , _ScalarOutT ], / ) -> NDArray [_ScalarOutT ]: ... # type: ignore[overload-overlap]
2165
2169
@overload
2170
+ def __radd__ (self : _nt .CastsWithBuiltin [_T , _ScalarOutT ], x : _nt .SequenceND [_T ], / ) -> NDArray [_ScalarOutT ]: ...
2171
+ @overload
2172
+ def __radd__ (self : _nt .CastsWithInt [_ScalarOutT ], x : _nt .SequenceND [_nt .JustInt ], / ) -> NDArray [_ScalarOutT ]: ...
2173
+ @overload
2166
2174
def __radd__ (
2167
- self : NDArray [generic [_AnyItemT ]],
2168
- x : _nt .SequenceND [_AnyItemT ],
2169
- / ,
2170
- ) -> ndarray [tuple [int , ...], _DTypeT_co ]: ...
2175
+ self : _nt .CastsWithFloat [_ScalarOutT ], x : _nt .SequenceND [_nt .JustFloat ], /
2176
+ ) -> NDArray [_ScalarOutT ]: ...
2177
+ @overload
2178
+ def __radd__ (
2179
+ self : _nt .CastsWithComplex [_ScalarOutT ], x : _nt .SequenceND [_nt .JustComplex ], /
2180
+ ) -> NDArray [_ScalarOutT ]: ...
2171
2181
@overload
2172
2182
def __radd__ (self : NDArray [datetime64 ], x : _nt .CoTimeDelta_nd , / ) -> NDArray [datetime64 ]: ...
2173
2183
@overload
2174
2184
def __radd__ (self : NDArray [_nt .co_timedelta ], x : _nt .ToDateTime_nd , / ) -> NDArray [datetime64 ]: ...
2175
2185
@overload
2176
- def __radd__ (self : NDArray [object_ ], x : object , / ) -> NDArray [object_ ]: ...
2186
+ def __radd__ (self : NDArray [object_ ], x : object , / ) -> NDArray [object_ ]: ... # type: ignore[overload-cannot-match]
2177
2187
@overload
2178
2188
def __radd__ (self : NDArray [str_ ], x : _nt .ToString_nd [_T ], / ) -> _nt .StringArrayND [_T ]: ...
2179
2189
@overload
@@ -2183,11 +2193,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2183
2193
@overload # type: ignore[misc]
2184
2194
def __iadd__ (self : NDArray [_ScalarT ], x : _nt .Casts [_ScalarT ], / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2185
2195
@overload
2186
- def __iadd__ (
2187
- self : NDArray [generic [_AnyItemT ]],
2188
- x : _nt .SequenceND [_AnyItemT ],
2189
- / ,
2190
- ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2196
+ def __iadd__ (self : _nt .CastsWithBuiltin [_T , Any ], x : _nt .SequenceND [_T ], / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2191
2197
@overload
2192
2198
def __iadd__ (self : NDArray [datetime64 ], x : _nt .ToTimeDelta_nd , / ) -> ndarray [_ShapeT_co , _DTypeT_co ]: ...
2193
2199
@overload
@@ -4156,7 +4162,7 @@ class bool_(generic[_BoolItemT_co], Generic[_BoolItemT_co]):
4156
4162
@type_check_only
4157
4163
def __nep50__ (self , below : _nt .co_number | timedelta64 , above : Never , / ) -> bool_ : ...
4158
4164
@type_check_only
4159
- def __nep50_bool__ (self , / ) -> bool_ : ...
4165
+ def __nep50_builtin__ (self , / ) -> tuple [ py_bool , bool_ ] : ...
4160
4166
@type_check_only
4161
4167
def __nep50_int__ (self , / ) -> intp : ...
4162
4168
@type_check_only
@@ -4604,9 +4610,8 @@ class number(
4604
4610
generic [_NumberItemT_co ],
4605
4611
Generic [_BitT , _NumberItemT_co ],
4606
4612
):
4607
- @final
4608
4613
@type_check_only
4609
- def __nep50_bool__ (self , / ) -> Self : ...
4614
+ def __nep50_builtin__ (self , / ) -> tuple [ int , Self ] : ...
4610
4615
@final
4611
4616
@type_check_only
4612
4617
def __nep50_int__ (self , / ) -> Self : ...
@@ -5463,6 +5468,8 @@ complex256 = clongdouble
5463
5468
class object_ (_RealMixin , generic [Any ]):
5464
5469
@type_check_only
5465
5470
def __nep50__ (self , below : object_ , above : _nt .co_number | character , / ) -> object_ : ...
5471
+ @type_check_only
5472
+ def __nep50_builtin__ (self , / ) -> tuple [_JustBuiltinScalar , object_ ]: ...
5466
5473
5467
5474
#
5468
5475
@overload
@@ -5500,7 +5507,9 @@ class character(flexible[_CharacterItemT_co], Generic[_CharacterItemT_co]): # t
5500
5507
5501
5508
class bytes_ (character [bytes ], bytes ): # type: ignore[misc]
5502
5509
@type_check_only
5503
- def __nep50__ (self , below : bytes_ , above : bytes_ , / ) -> bytes_ : ...
5510
+ def __nep50__ (self , below : bytes_ | object_ , above : Never , / ) -> bytes_ : ...
5511
+ @type_check_only
5512
+ def __nep50_builtin__ (self , / ) -> tuple [_nt .JustBytes , bytes_ ]: ...
5504
5513
5505
5514
#
5506
5515
@overload
@@ -5514,7 +5523,9 @@ class bytes_(character[bytes], bytes): # type: ignore[misc]
5514
5523
5515
5524
class str_ (character [str ], str ): # type: ignore[misc]
5516
5525
@type_check_only
5517
- def __nep50__ (self , below : str | str_ , from_ : str_ , / ) -> str_ : ...
5526
+ def __nep50__ (self , below : str_ | object_ , above : Never , / ) -> str_ : ...
5527
+ @type_check_only
5528
+ def __nep50_builtin__ (self , / ) -> tuple [_nt .JustStr , str_ ]: ...
5518
5529
5519
5530
#
5520
5531
@overload
@@ -5544,7 +5555,10 @@ class void(flexible[bytes | tuple[Any, ...]]): # type: ignore[misc] # pyright:
5544
5555
def setfield (self , val : ArrayLike , dtype : DTypeLike , offset : int = ...) -> None : ...
5545
5556
5546
5557
class datetime64 (
5547
- _RealMixin , _CmpOpMixin [datetime64 , _ArrayLikeDT64_co ], generic [_DT64ItemT_co ], Generic [_DT64ItemT_co ]
5558
+ _RealMixin ,
5559
+ _CmpOpMixin [datetime64 , _ArrayLikeDT64_co ],
5560
+ generic [_DT64ItemT_co ],
5561
+ Generic [_DT64ItemT_co ],
5548
5562
):
5549
5563
@property
5550
5564
@override
@@ -5681,6 +5695,8 @@ class timedelta64(
5681
5695
):
5682
5696
@type_check_only
5683
5697
def __nep50__ (self , below : timedelta64 , above : _nt .co_integer , / ) -> timedelta64 : ...
5698
+ @type_check_only
5699
+ def __nep50_builtin__ (self , / ) -> tuple [int , timedelta64 ]: ...
5684
5700
5685
5701
#
5686
5702
@property
0 commit comments