@@ -26,11 +26,13 @@ from typing import (
2626 Generic ,
2727 Literal ,
2828 NoReturn ,
29+ Protocol ,
2930 final ,
3031 overload ,
3132 type_check_only ,
3233)
3334
35+ from _typeshed import SupportsGetItem
3436from matplotlib .axes import (
3537 Axes as PlotAxes ,
3638 SubplotBase ,
@@ -187,6 +189,7 @@ from pandas._typing import (
187189 ValueKeyFunc ,
188190 VoidDtypeArg ,
189191 WriteBuffer ,
192+ _T_co ,
190193 np_1darray ,
191194 np_ndarray_anyint ,
192195 np_ndarray_bool ,
@@ -203,6 +206,10 @@ from pandas.core.dtypes.dtypes import CategoricalDtype
203206
204207from pandas .plotting import PlotAccessor
205208
209+ @type_check_only
210+ class _SupportsAdd (Protocol [_T_co ]):
211+ def __add__ (self , value : Self , / ) -> _T_co : ...
212+
206213class _iLocIndexerSeries (_iLocIndexer , Generic [S1 ]):
207214 # get item
208215 @overload
@@ -3751,34 +3758,14 @@ class Series(IndexOpsMixin[S1], NDFrame):
37513758 numeric_only : _bool = False ,
37523759 ** kwargs : Any ,
37533760 ) -> float : ...
3754- @overload
37553761 def sum (
3756- self : Series [ Never ],
3762+ self : SupportsGetItem [ Scalar , _SupportsAdd [ _T ] ],
37573763 axis : AxisIndex | None = 0 ,
37583764 skipna : _bool | None = ...,
37593765 numeric_only : _bool = ...,
37603766 min_count : int = ...,
37613767 ** 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 : ...
37823769 def to_list (self ) -> list [S1 ]: ...
37833770 def tolist (self ) -> list [S1 ]: ...
37843771 def var (
0 commit comments