Textualize/textual · error · StyleValueError
cannot mix 'none' with other style flags
Error message
cannot mix 'none' with other style flags
What it means
When StyleFlagsProperty hands a multi-word value to rich's Style.parse and it fails, and the words include 'none' alongside others, this clearer StyleValueError replaces rich's generic syntax error. 'none' is a standalone flag meaning no styling and cannot be combined with bold, italic, etc.
Source
Thrown at src/textual/css/_style_properties.py:1104
elif isinstance(style_flags, Style):
if obj.set_rule(self.name, style_flags):
obj.refresh(children=True)
else:
words = [word.strip() for word in style_flags.split(" ")]
valid_word = VALID_STYLE_FLAGS.__contains__
for word in words:
if not valid_word(word):
raise StyleValueError(
f"unknown word {word!r} in style flags",
help_text=style_flags_property_help_text(
self.name, word, context="inline"
),
)
try:
style = Style.parse(style_flags)
except rich.errors.StyleSyntaxError as error:
if "none" in words and len(words) > 1:
raise StyleValueError(
"cannot mix 'none' with other style flags",
help_text=style_flags_property_help_text(
self.name, " ".join(words), context="inline"
),
) from None
raise error from None
if obj.set_rule(self.name, style):
obj.refresh(children=True)
class TransitionsProperty:
"""Descriptor for getting transitions properties"""
def __get__(
self, obj: StylesBase, objtype: type[StylesBase] | None = None
) -> dict[str, Transition]:
"""Get a mapping of properties to the transitions applied to them.
View on GitHub (pinned to 06dbeef4bb)
Solutions
- Remove 'none' when other flags are present, or use 'none' alone
- When building flags programmatically, filter out 'none' if any other flag is set
Example fix
# before styles.text_style = "none bold" # after styles.text_style = "bold"
Defensive patterns
Strategy: validation
Validate before calling
words = [w for w in flags.split() if w != "none"] or ["none"] styles.text_style = " ".join(words)
Prevention
- Never concatenate 'none' with other flags when composing styles dynamically
When it happens
Trigger: `styles.text_style = "none bold"`, `styles.text_style = "italic none"`, or `text-style: bold none;` in a stylesheet.
Common situations: Dynamically composing style flags and concatenating a default 'none' with user-chosen flags; misunderstanding 'none' as a resettable default.
Related errors
- unknown word {word!r} in style flags
- Expected a str, Path or list[str | Path] for the CSS_PATH.
- {self.name} must be one of {friendly_list(self._valid_values
- {self.name} must be a str
- invalid percentage value '{token}'
AI-assisted analysis of Textualize/textual@06dbeef4bb (2026-08-27).
Data as JSON: /api/errors/cf0ce9dba18ecfa4.
Report an issue: GitHub.