@@ -26,11 +26,13 @@ from typing import (
26
26
Generic ,
27
27
Literal ,
28
28
NoReturn ,
29
+ Protocol ,
29
30
final ,
30
31
overload ,
31
32
type_check_only ,
32
33
)
33
34
35
+ from _typeshed import SupportsGetItem
34
36
from matplotlib .axes import (
35
37
Axes as PlotAxes ,
36
38
SubplotBase ,
@@ -186,6 +188,7 @@ from pandas._typing import (
186
188
ValueKeyFunc ,
187
189
VoidDtypeArg ,
188
190
WriteBuffer ,
191
+ _T_co ,
189
192
np_1darray ,
190
193
np_ndarray_anyint ,
191
194
np_ndarray_bool ,
@@ -203,6 +206,10 @@ from pandas.core.dtypes.dtypes import CategoricalDtype
203
206
204
207
from pandas .plotting import PlotAccessor
205
208
209
+ @type_check_only
210
+ class _SupportsAdd (Protocol [_T_co ]):
211
+ def __add__ (self , value : Self , / ) -> _T_co : ...
212
+
206
213
class _iLocIndexerSeries (_iLocIndexer , Generic [S1 ]):
207
214
# get item
208
215
@overload
@@ -500,7 +507,9 @@ class Series(IndexOpsMixin[S1], NDFrame):
500
507
@property
501
508
def index (self ) -> Index : ...
502
509
@index .setter
503
- def index (self , idx : Index ) -> None : ...
510
+ def index (
511
+ self , idx : AnyArrayLike | SequenceNotStr [Hashable ] | tuple [Hashable , ...]
512
+ ) -> None : ...
504
513
@overload
505
514
def reset_index (
506
515
self ,
@@ -4144,34 +4153,14 @@ class Series(IndexOpsMixin[S1], NDFrame):
4144
4153
numeric_only : _bool = False ,
4145
4154
** kwargs : Any ,
4146
4155
) -> float : ...
4147
- @overload
4148
- def sum (
4149
- self : Series [Never ],
4150
- axis : AxisIndex | None = 0 ,
4151
- skipna : _bool | None = ...,
4152
- numeric_only : _bool = ...,
4153
- min_count : int = ...,
4154
- ** kwargs : Any ,
4155
- ) -> Any : ...
4156
- # between `Series[bool]` and `Series[int]`.
4157
- @overload
4158
4156
def sum (
4159
- self : Series [ bool ],
4157
+ self : SupportsGetItem [ Scalar , _SupportsAdd [ _T ] ],
4160
4158
axis : AxisIndex | None = 0 ,
4161
4159
skipna : _bool | None = ...,
4162
4160
numeric_only : _bool = ...,
4163
4161
min_count : int = ...,
4164
4162
** kwargs : Any ,
4165
- ) -> int : ...
4166
- @overload
4167
- def sum (
4168
- self : Series [S1 ],
4169
- axis : AxisIndex | None = 0 ,
4170
- skipna : _bool | None = ...,
4171
- numeric_only : _bool = ...,
4172
- min_count : int = ...,
4173
- ** kwargs : Any ,
4174
- ) -> S1 : ...
4163
+ ) -> _T : ...
4175
4164
def to_list (self ) -> list [S1 ]: ...
4176
4165
@overload # type: ignore[override]
4177
4166
def to_numpy (
0 commit comments