Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Type style pipe function params and tuple func
  • Loading branch information
paw-lu committed Jan 12, 2024
commit b1a3fc406e036bc3a6ef3d6eff5bd649b4bede93
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