Skip to content

Commit 579db3c

Browse files
committed
default Series to Series[Any]
1 parent f8a329d commit 579db3c

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

pandas-stubs/_typing.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ from typing import (
1818
Protocol,
1919
SupportsIndex,
2020
TypedDict,
21-
TypeVar,
2221
overload,
2322
)
2423

@@ -35,6 +34,7 @@ from pandas.core.tools.datetimes import FulldatetimeDict
3534
from typing_extensions import (
3635
ParamSpec,
3736
TypeAlias,
37+
TypeVar,
3838
)
3939

4040
from pandas._libs.interval import Interval
@@ -842,6 +842,7 @@ S1 = TypeVar(
842842
| CategoricalDtype
843843
| BaseOffset
844844
| list[str],
845+
default=Any,
845846
)
846847

847848
S2 = TypeVar(

pandas-stubs/core/frame.pyi

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ from pandas._libs.tslibs import BaseOffset
7575
from pandas._libs.tslibs.nattype import NaTType
7676
from pandas._libs.tslibs.offsets import DateOffset
7777
from pandas._typing import (
78-
S1,
78+
S2,
7979
AggFuncTypeBase,
8080
AggFuncTypeDictFrame,
8181
AggFuncTypeDictSeries,
@@ -1392,13 +1392,13 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
13921392
@overload
13931393
def apply(
13941394
self,
1395-
f: Callable[..., S1 | NAType],
1395+
f: Callable[..., S2 | NAType],
13961396
axis: AxisIndex = ...,
13971397
raw: _bool = ...,
13981398
result_type: None = ...,
13991399
args: Any = ...,
14001400
**kwargs: Any,
1401-
) -> Series[S1]: ...
1401+
) -> Series[S2]: ...
14021402
# Since non-scalar type T is not supported in Series[T],
14031403
# we separate this overload from the above one
14041404
@overload
@@ -1416,14 +1416,14 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
14161416
@overload
14171417
def apply(
14181418
self,
1419-
f: Callable[..., S1 | NAType],
1419+
f: Callable[..., S2 | NAType],
14201420
axis: Axis = ...,
14211421
raw: _bool = ...,
14221422
args: Any = ...,
14231423
*,
14241424
result_type: Literal["expand", "reduce"],
14251425
**kwargs: Any,
1426-
) -> Series[S1]: ...
1426+
) -> Series[S2]: ...
14271427
@overload
14281428
def apply(
14291429
self,
@@ -1477,14 +1477,14 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
14771477
@overload
14781478
def apply(
14791479
self,
1480-
f: Callable[..., S1 | NAType],
1480+
f: Callable[..., S2 | NAType],
14811481
raw: _bool = ...,
14821482
result_type: None = ...,
14831483
args: Any = ...,
14841484
*,
14851485
axis: AxisColumn,
14861486
**kwargs: Any,
1487-
) -> Series[S1]: ...
1487+
) -> Series[S2]: ...
14881488
@overload
14891489
def apply(
14901490
self,

pandas-stubs/core/groupby/generic.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ from typing_extensions import (
3030

3131
from pandas._libs.tslibs.timestamps import Timestamp
3232
from pandas._typing import (
33-
S1,
33+
S2,
3434
AggFuncTypeBase,
3535
AggFuncTypeFrame,
3636
ByT,
@@ -52,7 +52,7 @@ class NamedAgg(NamedTuple):
5252
column: str
5353
aggfunc: AggScalar
5454

55-
class SeriesGroupBy(GroupBy[Series[S1]], Generic[S1, ByT]):
55+
class SeriesGroupBy(GroupBy[Series[S2]], Generic[S2, ByT]):
5656
@overload
5757
def aggregate(
5858
self,
@@ -114,7 +114,7 @@ class SeriesGroupBy(GroupBy[Series[S1]], Generic[S1, ByT]):
114114
self,
115115
indices: TakeIndexer,
116116
**kwargs,
117-
) -> Series[S1]: ...
117+
) -> Series[S2]: ...
118118
def skew(
119119
self,
120120
skipna: bool = ...,
@@ -125,10 +125,10 @@ class SeriesGroupBy(GroupBy[Series[S1]], Generic[S1, ByT]):
125125
def plot(self) -> GroupByPlot[Self]: ...
126126
def nlargest(
127127
self, n: int = ..., keep: NsmallestNlargestKeep = ...
128-
) -> Series[S1]: ...
128+
) -> Series[S2]: ...
129129
def nsmallest(
130130
self, n: int = ..., keep: NsmallestNlargestKeep = ...
131-
) -> Series[S1]: ...
131+
) -> Series[S2]: ...
132132
def idxmin(self, skipna: bool = ...) -> Series: ...
133133
def idxmax(self, skipna: bool = ...) -> Series: ...
134134
def corr(
@@ -166,7 +166,7 @@ class SeriesGroupBy(GroupBy[Series[S1]], Generic[S1, ByT]):
166166
@final # type: ignore[misc]
167167
def __iter__( # pyright: ignore[reportIncompatibleMethodOverride]
168168
self,
169-
) -> Iterator[tuple[ByT, Series[S1]]]: ...
169+
) -> Iterator[tuple[ByT, Series[S2]]]: ...
170170

171171
_TT = TypeVar("_TT", bound=Literal[True, False])
172172

0 commit comments

Comments
 (0)