Skip to content

Commit 3a95013

Browse files
committed
simplify
1 parent ddfc56e commit 3a95013

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

pandas-stubs/_typing.pyi

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -824,30 +824,8 @@ MaskType: TypeAlias = Series[bool] | np_ndarray_bool | list[bool]
824824

825825
# Scratch types for generics
826826

827-
S1 = TypeVar(
828-
"S1",
829-
bound=str
830-
| bytes
831-
| datetime.date
832-
| datetime.time
833-
| bool
834-
| int
835-
| float
836-
| complex
837-
| Dtype
838-
| datetime.datetime # includes pd.Timestamp
839-
| datetime.timedelta # includes pd.Timedelta
840-
| Period
841-
| Interval
842-
| CategoricalDtype
843-
| BaseOffset
844-
| list[str],
845-
default=Any,
846-
)
847-
848-
S2 = TypeVar(
849-
"S2",
850-
bound=str
827+
SeriesDType: TypeAlias = (
828+
str
851829
| bytes
852830
| datetime.date
853831
| datetime.time
@@ -862,8 +840,11 @@ S2 = TypeVar(
862840
| Interval
863841
| CategoricalDtype
864842
| BaseOffset
865-
| list[str],
843+
| list[str]
866844
)
845+
S1 = TypeVar("S1", bound=SeriesDType, default=Any)
846+
# Like S1, but without `default=Any`.
847+
S2 = TypeVar("S2", bound=SeriesDType)
867848

868849
IndexingInt: TypeAlias = (
869850
int | np.int_ | np.integer | np.unsignedinteger | np.signedinteger | np.int8

pandas-stubs/core/frame.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
13911391
@overload
13921392
def apply(
13931393
self,
1394+
# Use S2 (TypeVar without `default=Any`) instead of S1 due to https://github.com/python/mypy/issues/19182.
13941395
f: Callable[..., S2 | NAType],
13951396
axis: AxisIndex = ...,
13961397
raw: _bool = ...,
@@ -1415,6 +1416,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
14151416
@overload
14161417
def apply(
14171418
self,
1419+
# Use S2 (TypeVar without `default=Any`) instead of S1 due to https://github.com/python/mypy/issues/19182.
14181420
f: Callable[..., S2 | NAType],
14191421
axis: Axis = ...,
14201422
raw: _bool = ...,
@@ -1476,6 +1478,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
14761478
@overload
14771479
def apply(
14781480
self,
1481+
# Use S2 (TypeVar without `default=Any`) instead of S1 due to https://github.com/python/mypy/issues/19182.
14791482
f: Callable[..., S2 | NAType],
14801483
raw: _bool = ...,
14811484
result_type: None = ...,

0 commit comments

Comments
 (0)