Skip to content

Commit 10c9012

Browse files
committed
reduce AggFuncType
1 parent 8179d3b commit 10c9012

File tree

5 files changed

+19
-31
lines changed

5 files changed

+19
-31
lines changed

pandas-stubs/_typing.pyi

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -595,24 +595,22 @@ IndexKeyFunc: TypeAlias = Callable[[Index], Index | AnyArrayLike] | None
595595

596596
# types of `func` kwarg for DataFrame.aggregate and Series.aggregate
597597
# More specific than what is in pandas
598-
AggFuncTypeBase: TypeAlias = ( # pyright: ignore[reportUnknownVariableType]
599-
Callable | str | np.ufunc
600-
)
598+
AggFuncTypeBase: TypeAlias = Callable[..., Any] | str | np.ufunc
601599
AggFuncTypeDictSeries: TypeAlias = Mapping[HashableT, AggFuncTypeBase]
602600
AggFuncTypeDictFrame: TypeAlias = Mapping[
603601
HashableT, AggFuncTypeBase | list[AggFuncTypeBase]
604602
]
605-
AggFuncTypeSeriesToFrame: TypeAlias = ( # pyright: ignore[reportUnknownVariableType]
606-
list[AggFuncTypeBase] | AggFuncTypeDictSeries
603+
AggFuncTypeSeriesToFrame: TypeAlias = (
604+
list[AggFuncTypeBase] | AggFuncTypeDictSeries[HashableT]
607605
)
608-
AggFuncTypeFrame: TypeAlias = ( # pyright: ignore[reportUnknownVariableType]
609-
AggFuncTypeBase | list[AggFuncTypeBase] | AggFuncTypeDictFrame
606+
AggFuncTypeFrame: TypeAlias = (
607+
AggFuncTypeBase | list[AggFuncTypeBase] | AggFuncTypeDictFrame[HashableT]
610608
)
611-
AggFuncTypeDict: TypeAlias = ( # pyright: ignore[reportUnknownVariableType]
612-
AggFuncTypeDictSeries | AggFuncTypeDictFrame
609+
AggFuncTypeDict: TypeAlias = (
610+
AggFuncTypeDictSeries[HashableT] | AggFuncTypeDictFrame[HashableT]
613611
)
614-
AggFuncType: TypeAlias = ( # pyright: ignore[reportUnknownVariableType]
615-
AggFuncTypeBase | list[AggFuncTypeBase] | AggFuncTypeDict
612+
AggFuncType: TypeAlias = (
613+
AggFuncTypeBase | list[AggFuncTypeBase] | AggFuncTypeDict[HashableT]
616614
)
617615

618616
# Not used in stubs

pandas-stubs/core/frame.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,12 @@ from pandas._libs.lib import _NoDefaultDoNotUse
8383
from pandas._libs.missing import NAType
8484
from pandas._libs.tslibs import BaseOffset
8585
from pandas._libs.tslibs.nattype import NaTType
86-
from pandas._typing import (
87-
AggFuncTypeFrame, # pyright: ignore[reportUnknownVariableType]
88-
)
8986
from pandas._typing import (
9087
S2,
88+
AggFuncTypeBase,
9189
AggFuncTypeDictFrame,
9290
AggFuncTypeDictSeries,
91+
AggFuncTypeFrame,
9392
AlignJoin,
9493
AnyAll,
9594
AnyArrayLike,
@@ -174,7 +173,6 @@ from pandas._typing import (
174173
np_ndarray_float,
175174
np_ndarray_num,
176175
)
177-
from pandas._typing import AggFuncTypeBase # pyright: ignore[reportUnknownVariableType]
178176

179177
from pandas.io.formats.style import Styler
180178
from pandas.plotting import PlotAccessor

pandas-stubs/core/groupby/generic.pyi

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@ from pandas.core.series import Series
2929
from typing_extensions import Self
3030

3131
from pandas._libs.tslibs.timestamps import Timestamp
32-
from pandas._typing import (
33-
AggFuncTypeFrame, # pyright: ignore[reportUnknownVariableType]
34-
)
3532
from pandas._typing import (
3633
S2,
3734
S3,
35+
AggFuncTypeBase,
36+
AggFuncTypeFrame,
3837
ByT,
3938
CorrelationMethod,
4039
Dtype,
@@ -49,7 +48,6 @@ from pandas._typing import (
4948
WindowingEngineKwargs,
5049
np_ndarray,
5150
)
52-
from pandas._typing import AggFuncTypeBase # pyright: ignore[reportUnknownVariableType]
5351

5452
AggScalar: TypeAlias = str | Callable[..., Any]
5553

@@ -97,7 +95,7 @@ class SeriesGroupBy(GroupBy[Series[S2]], Generic[S2, ByT]):
9795
engine_kwargs: WindowingEngineKwargs = ...,
9896
**kwargs: Any,
9997
) -> Series: ...
100-
agg = aggregate # pyright: ignore[reportUnknownVariableType]
98+
agg = aggregate
10199
@overload
102100
def transform(
103101
self,

pandas-stubs/core/series.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,14 @@ from pandas._libs.lib import _NoDefaultDoNotUse
135135
from pandas._libs.missing import NAType
136136
from pandas._libs.tslibs import BaseOffset
137137
from pandas._libs.tslibs.nattype import NaTType
138-
from pandas._typing import (
139-
AggFuncTypeSeriesToFrame, # pyright: ignore[reportUnknownVariableType]
140-
)
141138
from pandas._typing import (
142139
S1,
143140
S2,
144141
S2_NSDT,
145142
T_COMPLEX,
143+
AggFuncTypeBase,
146144
AggFuncTypeDictFrame,
145+
AggFuncTypeSeriesToFrame,
147146
AnyAll,
148147
AnyArrayLike,
149148
ArrayLike,
@@ -246,7 +245,6 @@ from pandas._typing import (
246245
np_ndarray_str,
247246
np_ndarray_td,
248247
)
249-
from pandas._typing import AggFuncTypeBase # pyright: ignore[reportUnknownVariableType]
250248

251249
from pandas.core.dtypes.base import ExtensionDtype
252250
from pandas.core.dtypes.dtypes import CategoricalDtype

pandas-stubs/core/window/rolling.pyi

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,9 @@ from typing_extensions import Self
1919

2020
from pandas._libs.tslibs import BaseOffset
2121
from pandas._typing import (
22-
AggFuncTypeFrame, # pyright: ignore[reportUnknownVariableType]
23-
)
24-
from pandas._typing import (
25-
AggFuncTypeSeriesToFrame, # pyright: ignore[reportUnknownVariableType]
26-
)
27-
from pandas._typing import (
22+
AggFuncTypeBase,
23+
AggFuncTypeFrame,
24+
AggFuncTypeSeriesToFrame,
2825
AxisInt,
2926
CalculationMethod,
3027
IntervalClosedType,
@@ -34,7 +31,6 @@ from pandas._typing import (
3431
WindowingEngineKwargs,
3532
WindowingRankType,
3633
)
37-
from pandas._typing import AggFuncTypeBase # pyright: ignore[reportUnknownVariableType]
3834

3935
class BaseWindow(SelectionMixin[NDFrameT]):
4036
on: str | Index | None

0 commit comments

Comments
 (0)