Skip to content

Commit 943fc3c

Browse files
committed
Type style pipe function params and tuple func
1 parent 519cd7e commit 943fc3c

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

pandas/io/formats/style.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import operator
1010
from typing import (
1111
TYPE_CHECKING,
12-
Any,
1312
Callable,
1413
overload,
1514
)
@@ -66,15 +65,20 @@
6665
from matplotlib.colors import Colormap
6766

6867
from pandas._typing import (
68+
Any,
6969
Axis,
7070
AxisInt,
71+
Concatenate,
7172
FilePath,
7273
IndexLabel,
7374
IntervalClosedType,
7475
Level,
76+
P,
7577
QuantileInterpolation,
7678
Scalar,
79+
Self,
7780
StorageOptions,
81+
T,
7882
WriteBuffer,
7983
WriteExcelBuffer,
8084
)
@@ -3614,7 +3618,30 @@ class MyStyler(cls): # type: ignore[valid-type,misc]
36143618

36153619
return MyStyler
36163620

3617-
def pipe(self, func: Callable, *args, **kwargs):
3621+
@overload
3622+
def pipe(
3623+
self,
3624+
func: Callable[Concatenate[Self, P], T],
3625+
*args: P.args,
3626+
**kwargs: P.kwargs,
3627+
) -> T:
3628+
...
3629+
3630+
@overload
3631+
def pipe(
3632+
self,
3633+
func: tuple[Callable[..., T], str],
3634+
*args: Any,
3635+
**kwargs: Any,
3636+
) -> T:
3637+
...
3638+
3639+
def pipe(
3640+
self,
3641+
func: Callable[Concatenate[Self, P], T] | tuple[Callable[..., T], str],
3642+
*args: Any,
3643+
**kwargs: Any,
3644+
) -> T:
36183645
"""
36193646
Apply ``func(self, *args, **kwargs)``, and return the result.
36203647

0 commit comments

Comments
 (0)