Skip to content

Commit

Permalink
Type style pipe function params and tuple func
Browse files Browse the repository at this point in the history
  • Loading branch information
paw-lu committed Jan 8, 2024
1 parent 2134d98 commit 142d749
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import operator
from typing import (
TYPE_CHECKING,
Any,
Callable,
overload,
)
Expand Down Expand Up @@ -66,15 +65,20 @@
from matplotlib.colors import Colormap

from pandas._typing import (
Any,
Axis,
AxisInt,
Concatenate,
FilePath,
IndexLabel,
IntervalClosedType,
Level,
P,
QuantileInterpolation,
Scalar,
Self,
StorageOptions,
T,
WriteBuffer,
WriteExcelBuffer,
)
Expand Down Expand Up @@ -3614,7 +3618,30 @@ class MyStyler(cls): # type: ignore[valid-type,misc]

return MyStyler

def pipe(self, func: Callable, *args, **kwargs):
@overload
def pipe(
self,
func: Callable[Concatenate[Self, P], T],
*args: P.args,
**kwargs: P.kwargs,
) -> T:
...

@overload
def pipe(
self,
func: tuple[Callable[..., T], str],
*args: Any,
**kwargs: Any,
) -> T:
...

def pipe(
self,
func: Callable[Concatenate[Self, P], T] | tuple[Callable[..., T], str],
*args: Any,
**kwargs: Any,
) -> T:
"""
Apply ``func(self, *args, **kwargs)``, and return the result.
Expand Down

0 comments on commit 142d749

Please sign in to comment.