Textualize/textual · error · InvalidLineStyle
Valid rule line styles are {friendly_list(_VALID_LINE_STYLES
Error message
Valid rule line styles are {friendly_list(_VALID_LINE_STYLES)} What it means
Raised by Rule.validate_line_style reactive validator when line_style is not in _VALID_LINE_STYLES (e.g. 'solid', 'heavy', 'double', 'dashed', ... — see the module constants). Assignment of an unknown style raises InvalidLineStyle at set time.
Source
Thrown at src/textual/widgets/_rule.py:195
f"Valid rule orientations are {friendly_list(_VALID_RULE_ORIENTATIONS)}"
)
def watch_orientation(
self, old_orientation: RuleOrientation, orientation: RuleOrientation
) -> None:
self.remove_class(f"-{old_orientation}")
self.add_class(f"-{orientation}")
def validate_orientation(self, orientation: RuleOrientation) -> RuleOrientation:
if orientation not in _VALID_RULE_ORIENTATIONS:
raise InvalidRuleOrientation(
f"Valid rule orientations are {friendly_list(_VALID_RULE_ORIENTATIONS)}"
)
return orientation
def validate_line_style(self, style: LineStyle) -> LineStyle:
if style not in _VALID_LINE_STYLES:
raise InvalidLineStyle(
f"Valid rule line styles are {friendly_list(_VALID_LINE_STYLES)}"
)
return style
def get_content_width(self, container: Size, viewport: Size) -> int:
if self.orientation == "horizontal":
return container.width
return 1
def get_content_height(self, container: Size, viewport: Size, width: int) -> int:
if self.orientation == "horizontal":
return 1
return container.height
@classmethod
def horizontal(
cls,
line_style: LineStyle = "solid",View on GitHub (pinned to 06dbeef4bb)
Solutions
- Check _VALID_LINE_STYLES in textual/widgets/_rule.py and use an exact name (e.g. 'solid', 'heavy', 'dashed').
- Avoid inventing styles; pick the closest valid one.
- Pin/verify your Textual version's supported styles.
Example fix
# before Rule(line_style='dotted') # after Rule(line_style='dashed')
Defensive patterns
Strategy: type-guard
Validate before calling
from textual.widgets._rule import _VALID_LINE_STYLES assert style in _VALID_LINE_STYLES
Type guard
def is_line_style(s: str) -> bool: return s in _VALID_LINE_STYLES
Prevention
- Use exact style names from _VALID_LINE_STYLES
- Pin Textual version to keep style set stable
When it happens
Trigger: Rule(line_style='dotted') or rule.line_style = 'ascii' where those names are not in the valid set.
Common situations: Guessing style names, copying styles valid in CSS borders but not Rule, or Textual version differences in supported styles.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Valid rule orientations are {friendly_list(_VALID_RULE_ORIEN
- {self.name} must be a str (e.g. '10%') or a float (e.g. 0.1)
- Expected a character or hatch value here; found {character!r
- {token!r} is not a valid scalar
- {name!r} is an invalid {description}; identifiers must conta
AI-assisted analysis of Textualize/textual@06dbeef4bb (2026-08-27).
Data as JSON: /api/errors/69a5d78deed4bc59.
Report an issue: GitHub.