1212 Any ,
1313 Callable ,
1414 DefaultDict ,
15- Dict ,
1615 Hashable ,
1716 Iterable ,
1817 List ,
19- Optional ,
2018 Sequence ,
21- Tuple ,
22- Union ,
2319 cast ,
2420)
2521
4743
4844
4945def reconstruct_func (
50- func : Optional [ AggFuncType ] , ** kwargs
51- ) -> Tuple [bool , Optional [ AggFuncType ], Optional [ List [ str ]], Optional [ List [ int ]] ]:
46+ func : AggFuncType | None , ** kwargs
47+ ) -> tuple [bool , AggFuncType | None , list [ str ] | None , list [ int ] | None ]:
5248 """
5349 This is the internal function to reconstruct func given if there is relabeling
5450 or not and also normalize the keyword to get new order of columns.
@@ -86,8 +82,8 @@ def reconstruct_func(
8682 (False, 'min', None, None)
8783 """
8884 relabeling = func is None and is_multi_agg_with_relabel (** kwargs )
89- columns : Optional [ List [ str ]] = None
90- order : Optional [ List [ int ]] = None
85+ columns : list [ str ] | None = None
86+ order : list [ int ] | None = None
9187
9288 if not relabeling :
9389 if isinstance (func , list ) and len (func ) > len (set (func )):
@@ -134,7 +130,7 @@ def is_multi_agg_with_relabel(**kwargs) -> bool:
134130 )
135131
136132
137- def normalize_keyword_aggregation (kwargs : dict ) -> Tuple [dict , List [str ], List [int ]]:
133+ def normalize_keyword_aggregation (kwargs : dict ) -> tuple [dict , list [str ], list [int ]]:
138134 """
139135 Normalize user-provided "named aggregation" kwargs.
140136 Transforms from the new ``Mapping[str, NamedAgg]`` style kwargs
@@ -190,8 +186,8 @@ def normalize_keyword_aggregation(kwargs: dict) -> Tuple[dict, List[str], List[i
190186
191187
192188def _make_unique_kwarg_list (
193- seq : Sequence [Tuple [Any , Any ]]
194- ) -> Sequence [Tuple [Any , Any ]]:
189+ seq : Sequence [tuple [Any , Any ]]
190+ ) -> Sequence [tuple [Any , Any ]]:
195191 """
196192 Uniquify aggfunc name of the pairs in the order list
197193
@@ -295,10 +291,10 @@ def maybe_mangle_lambdas(agg_spec: Any) -> Any:
295291
296292def relabel_result (
297293 result : FrameOrSeries ,
298- func : Dict [str , List [ Union [ Callable , str ] ]],
294+ func : dict [str , list [ Callable | str ]],
299295 columns : Iterable [Hashable ],
300296 order : Iterable [int ],
301- ) -> Dict [Hashable , Series ]:
297+ ) -> dict [Hashable , Series ]:
302298 """
303299 Internal function to reorder result if relabelling is True for
304300 dataframe.agg, and return the reordered result in dict.
@@ -325,7 +321,7 @@ def relabel_result(
325321 reordered_indexes = [
326322 pair [0 ] for pair in sorted (zip (columns , order ), key = lambda t : t [1 ])
327323 ]
328- reordered_result_in_dict : Dict [Hashable , Series ] = {}
324+ reordered_result_in_dict : dict [Hashable , Series ] = {}
329325 idx = 0
330326
331327 reorder_mask = not isinstance (result , ABCSeries ) and len (result .columns ) > 1
@@ -369,7 +365,7 @@ def relabel_result(
369365
370366def validate_func_kwargs (
371367 kwargs : dict ,
372- ) -> Tuple [ List [str ], List [ Union [ str , Callable [..., Any ] ]]]:
368+ ) -> tuple [ list [str ], list [ str | Callable [..., Any ]]]:
373369 """
374370 Validates types of user-provided "named aggregation" kwargs.
375371 `TypeError` is raised if aggfunc is not `str` or callable.
@@ -495,7 +491,7 @@ def transform_dict_like(
495491 # GH 15931 - deprecation of renaming keys
496492 raise SpecificationError ("nested renamer is not supported" )
497493
498- results : Dict [Hashable , FrameOrSeriesUnion ] = {}
494+ results : dict [Hashable , FrameOrSeriesUnion ] = {}
499495 for name , how in func .items ():
500496 colg = obj ._gotitem (name , ndim = 1 )
501497 try :
@@ -536,7 +532,7 @@ def transform_str_or_callable(
536532
537533def agg_list_like (
538534 obj : AggObjType ,
539- arg : List [AggFuncTypeBase ],
535+ arg : list [AggFuncTypeBase ],
540536 _axis : int ,
541537) -> FrameOrSeriesUnion :
542538 """
0 commit comments