Skip to content

Commit ee2fdd9

Browse files
committed
add types
1 parent 7323c60 commit ee2fdd9

File tree

1 file changed

+22
-33
lines changed

1 file changed

+22
-33
lines changed

pandas/io/formats/style.py

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
Optional,
1919
Sequence,
2020
Tuple,
21+
TypedDict,
2122
Union,
2223
)
2324
from uuid import uuid4
2425

2526
import numpy as np
26-
from typing_extensions import TypedDict
2727

2828
from pandas._config import get_option
2929

@@ -1233,19 +1233,19 @@ def set_table_styles(
12331233
obj, idf = self.data.index, ".row"
12341234

12351235
table_styles = [
1236-
{
1237-
"selector": str(s["selector"]) + idf + str(obj.get_loc(key)),
1238-
"props": _maybe_convert_css_to_tuples(s["props"]),
1239-
}
1236+
CSSDict(
1237+
selector=str(s["selector"]) + idf + str(obj.get_loc(key)),
1238+
props=_maybe_convert_css_to_tuples(s["props"]),
1239+
)
12401240
for key, styles in table_styles.items()
12411241
for s in styles
12421242
]
12431243
else:
12441244
table_styles = [
1245-
{
1246-
"selector": s["selector"],
1247-
"props": _maybe_convert_css_to_tuples(s["props"]),
1248-
}
1245+
CSSDict(
1246+
selector=s["selector"],
1247+
props=_maybe_convert_css_to_tuples(s["props"]),
1248+
)
12491249
for s in table_styles
12501250
]
12511251

@@ -1875,10 +1875,10 @@ def _class_styles(self):
18751875
styles : List
18761876
"""
18771877
return [
1878-
{
1879-
"selector": f".{self.class_name}",
1880-
"props": _maybe_convert_css_to_tuples(self.class_properties),
1881-
}
1878+
CSSDict(
1879+
selector=f".{self.class_name}",
1880+
props=_maybe_convert_css_to_tuples(self.class_properties),
1881+
)
18821882
]
18831883

18841884
def _pseudo_css(self, uuid: str, name: str, row: int, col: int, text: str):
@@ -1912,27 +1912,16 @@ def _pseudo_css(self, uuid: str, name: str, row: int, col: int, text: str):
19121912
-------
19131913
pseudo_css : List
19141914
"""
1915+
selector_id = "#T_" + uuid + "row" + str(row) + "_col" + str(col)
19151916
return [
1916-
{
1917-
"selector": "#T_"
1918-
+ uuid
1919-
+ "row"
1920-
+ str(row)
1921-
+ "_col"
1922-
+ str(col)
1923-
+ f":hover .{name}",
1924-
"props": [("visibility", "visible")],
1925-
},
1926-
{
1927-
"selector": "#T_"
1928-
+ uuid
1929-
+ "row"
1930-
+ str(row)
1931-
+ "_col"
1932-
+ str(col)
1933-
+ f" .{name}::after",
1934-
"props": [("content", f'"{text}"')],
1935-
},
1917+
CSSDict(
1918+
selector=selector_id + f":hover .{name}",
1919+
props=[("visibility", "visible")],
1920+
),
1921+
CSSDict(
1922+
selector=selector_id + f" .{name}::after",
1923+
props=[("content", f'"{text}"')],
1924+
),
19361925
]
19371926

19381927
def _translate(self, styler_data: FrameOrSeriesUnion, uuid: str, d: Dict):

0 commit comments

Comments
 (0)