{"record":{"id":"5c5e8f548537d1ce","repo":"Textualize/textual","slug":"stylesheeterrors-css-rules-renderable-summarizin","errorCode":null,"errorMessage":"StylesheetErrors(css_rules) (renderable summarizing CSS rule errors)","messagePattern":"StylesheetErrors\\(css_rules\\) \\(renderable summarizing CSS rule errors\\)","errorType":"exception","errorClass":"StylesheetParseError","httpStatus":null,"severity":"error","filePath":"src/textual/css/stylesheet.py","lineNumber":403,"sourceCode":"            scope,\n        ) in self.source.items():\n            if css in self._invalid_css:\n                continue\n            try:\n                css_rules = self._parse_rules(\n                    css,\n                    read_from=read_from,\n                    is_default_rules=is_default_rules,\n                    tie_breaker=tie_breaker,\n                    scope=scope,\n                )\n            except Exception:\n                self._invalid_css.add(css)\n                raise\n            if any(rule.errors for rule in css_rules):\n                error_renderable = StylesheetErrors(css_rules)\n                self._invalid_css.add(css)\n                raise StylesheetParseError(error_renderable)\n            add_rules(css_rules)\n        self._rules = rules\n        self._require_parse = False\n        self._rules_map = None\n\n    def reparse(self) -> None:\n        \"\"\"Re-parse source, applying new variables.\n\n        Raises:\n            StylesheetError: If the CSS could not be read.\n            StylesheetParseError: If the CSS is invalid.\n        \"\"\"\n        # Do this in a fresh Stylesheet so if there are errors we don't break self.\n        stylesheet = Stylesheet(variables=self._variables)\n        for read_from, (css, is_defaults, tie_breaker, scope) in self.source.items():\n            stylesheet.add_source(\n                css,\n                read_from=read_from,","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/Textualize/textual/blob/06dbeef4bb70fb718236aa418ed658ef4667a126/src/textual/css/stylesheet.py#L385-L421","documentation":"Stylesheet.parse raises StylesheetParseError when any parsed CSS rule carries errors; the exception carries a StylesheetErrors renderable that summarizes each failing rule. Note: the raised object wraps the renderable, so str(exception) is not human-readable — print the exception's args or render it.","triggerScenarios":"A stylesheet containing at least one invalid declaration (bad property value, unknown property, malformed selector) after add_rules; parse() aggregates per-rule errors and raises once.","commonSituations":"Typos or unsupported properties in TCSS, copied CSS from web that Textual doesn't support, or Textual version upgrades that renamed properties.","solutions":["Inspect the StylesheetErrors renderable (e.g. print(exc.args[0]) or use Console to render it) to see line numbers and messages","Fix or remove the listed rules","Lint your TCSS in CI by calling Stylesheet.parse on app CSS in a test"],"exampleFix":"# before\nraise err  # opaque\n# after\ntry:\n    stylesheet.parse()\nexcept StylesheetParseError as e:\n    from rich.console import Console\n    Console().print(e.args[0])","handlingStrategy":"try-catch","validationCode":"from textual.css.stylesheet import StylesheetParseError\n# in a test:\nss = Stylesheet(); ss.read(path)\ntry:\n    ss.parse()\nexcept StylesheetParseError as e:\n    raise AssertionError(f\"{path} has CSS errors\") from e","typeGuard":null,"tryCatchPattern":"from textual.css.stylesheet import StylesheetParseError\nfrom rich.console import Console\ntry:\n    stylesheet.parse()\nexcept StylesheetParseError as e:\n    Console().print(e.args[0])  # renderable summary with line numbers","preventionTips":["Render e.args[0] to see the human-readable error table","Parse all app CSS in a CI test","Avoid copying unsupported web-CSS properties"],"tags":["textual","css","stylesheet","parse","renderable"],"backgroundTag":"css-value-parse-error","analyzedSha":"06dbeef4bb70fb718236aa418ed658ef4667a126","analyzedAt":"2026-08-27T02:36:57.214Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}