Skip to content

Commit 64027e6

Browse files
authored
TYP: obj in aggregation.py (#37532)
1 parent d9e5438 commit 64027e6

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

pandas/_typing.py

+11
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@
3535
from pandas.core.arrays.base import ExtensionArray # noqa: F401
3636
from pandas.core.frame import DataFrame
3737
from pandas.core.generic import NDFrame # noqa: F401
38+
from pandas.core.groupby.generic import DataFrameGroupBy, SeriesGroupBy
3839
from pandas.core.indexes.base import Index
40+
from pandas.core.resample import Resampler
3941
from pandas.core.series import Series
42+
from pandas.core.window.rolling import BaseWindow
4043

4144
from pandas.io.formats.format import EngFormatter
4245

@@ -115,6 +118,14 @@
115118
List[AggFuncTypeBase],
116119
AggFuncTypeDict,
117120
]
121+
AggObjType = Union[
122+
"Series",
123+
"DataFrame",
124+
"SeriesGroupBy",
125+
"DataFrameGroupBy",
126+
"BaseWindow",
127+
"Resampler",
128+
]
118129

119130

120131
# for arbitrary kwargs passed during reading/writing files

pandas/core/aggregation.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
AggFuncType,
2525
AggFuncTypeBase,
2626
AggFuncTypeDict,
27+
AggObjType,
2728
Axis,
2829
FrameOrSeries,
2930
FrameOrSeriesUnion,
@@ -530,7 +531,7 @@ def transform_str_or_callable(
530531

531532

532533
def aggregate(
533-
obj,
534+
obj: AggObjType,
534535
arg: AggFuncType,
535536
*args,
536537
**kwargs,
@@ -580,7 +581,7 @@ def aggregate(
580581

581582

582583
def agg_list_like(
583-
obj,
584+
obj: AggObjType,
584585
arg: List[AggFuncTypeBase],
585586
_axis: int,
586587
) -> FrameOrSeriesUnion:
@@ -672,7 +673,7 @@ def agg_list_like(
672673

673674

674675
def agg_dict_like(
675-
obj,
676+
obj: AggObjType,
676677
arg: AggFuncTypeDict,
677678
_axis: int,
678679
) -> FrameOrSeriesUnion:

0 commit comments

Comments
 (0)