Skip to content

Commit a02544b

Browse files
authored
maybe_convert_css_to_tuples() raises on strings without ":"
1 parent 28ec59c commit a02544b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pandas/io/formats/style_render.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,18 +2069,18 @@ def maybe_convert_css_to_tuples(style: CSSProperties) -> CSSList:
20692069
('border','1px solid red')]
20702070
"""
20712071
if isinstance(style, str):
2072-
s = style.split(";")
2073-
try:
2074-
return [
2075-
(x.split(":")[0].strip(), ":".join(x.split(":")[1:]).strip())
2076-
for x in s
2077-
if ":".join(x.split(":")[1:]).strip() != ""
2078-
]
2079-
except IndexError as err:
2072+
if ":" not in style:
20802073
raise ValueError(
20812074
"Styles supplied as string must follow CSS rule formats, "
2082-
f"for example 'attr: val;'. '{style}' was given."
2083-
) from err
2075+
+f"for example 'attr: val;'. '{style}' was given."
2076+
)
2077+
s = style.split(";")
2078+
return [
2079+
(x.split(":")[0].strip(), ":".join(x.split(":")[1:]).strip())
2080+
for x in s
2081+
if ":".join(x.split(":")[1:]).strip() != ""
2082+
]
2083+
20842084
return style
20852085

20862086

0 commit comments

Comments
 (0)