@@ -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 ,
@@ -187,6 +189,7 @@ from pandas._typing import (
187
189
ValueKeyFunc ,
188
190
VoidDtypeArg ,
189
191
WriteBuffer ,
192
+ _T_co ,
190
193
np_1darray ,
191
194
np_ndarray_anyint ,
192
195
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
@@ -3751,34 +3758,14 @@ class Series(IndexOpsMixin[S1], NDFrame):
3751
3758
numeric_only : _bool = False ,
3752
3759
** kwargs : Any ,
3753
3760
) -> float : ...
3754
- @overload
3755
3761
def sum (
3756
- self : Series [ Never ],
3762
+ self : SupportsGetItem [ Scalar , _SupportsAdd [ _T ] ],
3757
3763
axis : AxisIndex | None = 0 ,
3758
3764
skipna : _bool | None = ...,
3759
3765
numeric_only : _bool = ...,
3760
3766
min_count : int = ...,
3761
3767
** kwargs : Any ,
3762
- ) -> Any : ...
3763
- # between `Series[bool]` and `Series[int]`.
3764
- @overload
3765
- def sum (
3766
- self : Series [bool ],
3767
- axis : AxisIndex | None = 0 ,
3768
- skipna : _bool | None = ...,
3769
- numeric_only : _bool = ...,
3770
- min_count : int = ...,
3771
- ** kwargs : Any ,
3772
- ) -> int : ...
3773
- @overload
3774
- def sum (
3775
- self : Series [S1 ],
3776
- axis : AxisIndex | None = 0 ,
3777
- skipna : _bool | None = ...,
3778
- numeric_only : _bool = ...,
3779
- min_count : int = ...,
3780
- ** kwargs : Any ,
3781
- ) -> S1 : ...
3768
+ ) -> _T : ...
3782
3769
def to_list (self ) -> list [S1 ]: ...
3783
3770
def tolist (self ) -> list [S1 ]: ...
3784
3771
def var (
0 commit comments