Skip to content

Commit 74ac551

Browse files
committed
TYP: Add typing for StylerRenderer
1 parent 32bc72f commit 74ac551

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

pandas-stubs/io/formats/style_render.pyi

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import (
22
Any,
33
Callable,
4+
Literal,
45
Optional,
56
Sequence,
67
TypedDict,
@@ -10,9 +11,12 @@ from typing import (
1011
import jinja2
1112
from pandas import Index
1213

13-
from pandas._typing import Level
14+
from pandas._typing import (
15+
HashableT,
16+
Level,
17+
)
1418

15-
BaseFormatter = Union[str, Callable]
19+
BaseFormatter = Union[str, Callable[[object], str]]
1620
ExtFormatter = Union[BaseFormatter, dict[Any, Optional[BaseFormatter]]]
1721
CSSPair = tuple[str, Union[str, float]]
1822
CSSList = list[CSSPair]
@@ -23,7 +27,7 @@ class CSSDict(TypedDict):
2327
props: CSSProperties
2428

2529
CSSStyles = list[CSSDict]
26-
Subset = Union[slice, Sequence, Index]
30+
Subset = Union[slice, list[HashableT], Index]
2731

2832
class StylerRenderer:
2933
loader: jinja2.loaders.BaseLoader
@@ -41,17 +45,17 @@ class StylerRenderer:
4145
decimal: str = ...,
4246
thousands: str | None = ...,
4347
escape: str | None = ...,
44-
hyperlinks: str | None = ...,
48+
hyperlinks: Literal["html", "latex"] | None = ...,
4549
) -> StylerRenderer: ...
4650
def format_index(
4751
self,
4852
formatter: ExtFormatter | None = ...,
49-
axis: int | str = ...,
53+
axis: int | Literal["index", "columns"] = ...,
5054
level: Level | list[Level] | None = ...,
5155
na_rep: str | None = ...,
5256
precision: int | None = ...,
5357
decimal: str = ...,
5458
thousands: str | None = ...,
5559
escape: str | None = ...,
56-
hyperlinks: str | None = ...,
60+
hyperlinks: Literal["html", "latex"] | None = ...,
5761
) -> StylerRenderer: ...

0 commit comments

Comments
 (0)