Textualize/textual · error · InvalidRuleOrientation
Valid rule orientations are {friendly_list(_VALID_RULE_ORIEN
Error message
Valid rule orientations are {friendly_list(_VALID_RULE_ORIENTATIONS)} What it means
Raised by Rule.render when the orientation reactive is neither 'horizontal' nor 'vertical' — render handles horizontal and vertical branches and this else covers any other value. In practice it is hard to reach because validate_orientation also guards assignment, but a corrupted/orientation set via internals would hit it at render time.
Source
Thrown at src/textual/widgets/_rule.py:176
self.orientation = orientation
self.line_style = line_style
self.expand = True
def render(self) -> RenderResult:
rule_character: str
style = self.rich_style
if self.orientation == "vertical":
rule_character = _VERTICAL_LINE_CHARS[self.line_style]
return VerticalRuleRenderable(
rule_character, style, self.content_size.height
)
elif self.orientation == "horizontal":
rule_character = _HORIZONTAL_LINE_CHARS[self.line_style]
return HorizontalRuleRenderable(
rule_character, style, self.content_size.width
)
else:
raise InvalidRuleOrientation(
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:View on GitHub (pinned to 06dbeef4bb)
Solutions
- Use only 'horizontal' or 'vertical' (the RuleOrientation literal values).
- Assign through the public constructor/reactive so validate_orientation catches mistakes early.
- Check _VALID_RULE_ORIENTATIONS in textual/widgets/_rule.py.
Example fix
# before Rule(orientation='diag') # after Rule(orientation='horizontal')
Defensive patterns
Strategy: type-guard
Type guard
def is_orientation(v: str) -> bool: return v in ('horizontal', 'vertical') Prevention
- Only use 'horizontal' or 'vertical'
- Let validate_orientation catch bad values at assignment, never bypass reactives
When it happens
Trigger: Rule(orientation='diagonal') or rule.orientation = 'up' — an invalid orientation string reaching render; typically blocked earlier by validate_orientation raising at assignment time.
Common situations: Passing a custom string that type-checks as RuleOrientation in loose typing, or bypassing validation via internal state.
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 line styles are {friendly_list(_VALID_LINE_STYLES
- {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/0d7cff1e2b8b1ffc.
Report an issue: GitHub.