Skip to content

Commit b9e90dc

Browse files
authored
typing of callable for apply methods in styler (#43148)
Co-authored-by: JHM Darbyshire (iMac) <[email protected]>
1 parent cf791c8 commit b9e90dc

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

pandas/io/formats/style.py

+10-18
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ def clear(self) -> None:
11401140

11411141
def _apply(
11421142
self,
1143-
func: Callable[..., Styler],
1143+
func: Callable,
11441144
axis: Axis | None = 0,
11451145
subset: Subset | None = None,
11461146
**kwargs,
@@ -1195,7 +1195,7 @@ def _apply(
11951195

11961196
def apply(
11971197
self,
1198-
func: Callable[..., Styler],
1198+
func: Callable,
11991199
axis: Axis | None = 0,
12001200
subset: Subset | None = None,
12011201
**kwargs,
@@ -1290,7 +1290,7 @@ def apply(
12901290

12911291
def _apply_index(
12921292
self,
1293-
func: Callable[..., Styler],
1293+
func: Callable,
12941294
axis: int | str = 0,
12951295
level: Level | list[Level] | None = None,
12961296
method: str = "apply",
@@ -1325,7 +1325,7 @@ def _apply_index(
13251325
)
13261326
def apply_index(
13271327
self,
1328-
func: Callable[..., Styler],
1328+
func: Callable,
13291329
axis: int | str = 0,
13301330
level: Level | list[Level] | None = None,
13311331
**kwargs,
@@ -1411,7 +1411,7 @@ def apply_index(
14111411
)
14121412
def applymap_index(
14131413
self,
1414-
func: Callable[..., Styler],
1414+
func: Callable,
14151415
axis: int | str = 0,
14161416
level: Level | list[Level] | None = None,
14171417
**kwargs,
@@ -2597,11 +2597,7 @@ def f(data: DataFrame, props: str) -> np.ndarray:
25972597

25982598
if props is None:
25992599
props = f"background-color: {null_color};"
2600-
# error: Argument 1 to "apply" of "Styler" has incompatible type
2601-
# "Callable[[DataFrame, str], ndarray]"; expected "Callable[..., Styler]"
2602-
return self.apply(
2603-
f, axis=None, subset=subset, props=props # type: ignore[arg-type]
2604-
)
2600+
return self.apply(f, axis=None, subset=subset, props=props)
26052601

26062602
def highlight_max(
26072603
self,
@@ -2645,10 +2641,8 @@ def highlight_max(
26452641

26462642
if props is None:
26472643
props = f"background-color: {color};"
2648-
# error: Argument 1 to "apply" of "Styler" has incompatible type
2649-
# "Callable[[FrameOrSeries, str], ndarray]"; expected "Callable[..., Styler]"
26502644
return self.apply(
2651-
partial(_highlight_value, op="max"), # type: ignore[arg-type]
2645+
partial(_highlight_value, op="max"),
26522646
axis=axis,
26532647
subset=subset,
26542648
props=props,
@@ -2696,10 +2690,8 @@ def highlight_min(
26962690

26972691
if props is None:
26982692
props = f"background-color: {color};"
2699-
# error: Argument 1 to "apply" of "Styler" has incompatible type
2700-
# "Callable[[FrameOrSeries, str], ndarray]"; expected "Callable[..., Styler]"
27012693
return self.apply(
2702-
partial(_highlight_value, op="min"), # type: ignore[arg-type]
2694+
partial(_highlight_value, op="min"),
27032695
axis=axis,
27042696
subset=subset,
27052697
props=props,
@@ -2805,7 +2797,7 @@ def highlight_between(
28052797
if props is None:
28062798
props = f"background-color: {color};"
28072799
return self.apply(
2808-
_highlight_between, # type: ignore[arg-type]
2800+
_highlight_between,
28092801
axis=axis,
28102802
subset=subset,
28112803
props=props,
@@ -2911,7 +2903,7 @@ def highlight_quantile(
29112903
if props is None:
29122904
props = f"background-color: {color};"
29132905
return self.apply(
2914-
_highlight_between, # type: ignore[arg-type]
2906+
_highlight_between,
29152907
axis=axis_apply,
29162908
subset=subset,
29172909
props=props,

0 commit comments

Comments
 (0)