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

  1. Remove 'none' when other flags are present, or use 'none' alone
  2. 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

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


AI-assisted analysis of Textualize/textual@06dbeef4bb (2026-08-27). Data as JSON: /api/errors/cf0ce9dba18ecfa4. Report an issue: GitHub.