{"record":{"id":"4ed48da13bae7856","repo":"Textualize/textual","slug":"expected-a-character-or-hatch-value-here-found-c","errorCode":null,"errorMessage":"Expected a character or hatch value here; found {character!r}","messagePattern":"Expected a character or hatch value here; found (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/textual/css/_style_properties.py","lineNumber":1249,"sourceCode":"\n    def __set__(\n        self, obj: StylesBase, value: tuple[str, Color | str] | Literal[\"none\"] | None\n    ) -> None:\n        _rich_traceback_omit = True\n        if value is None:\n            if obj.clear_rule(\"hatch\"):\n                obj.refresh(children=True)\n            return\n\n        if value == \"none\":\n            hatch = \"none\"\n        else:\n            character, color = value\n            if len(character) != 1:\n                try:\n                    character = HATCHES[character]\n                except KeyError:\n                    raise ValueError(\n                        f\"Expected a character or hatch value here; found {character!r}\"\n                    ) from None\n            if cell_len(character) != 1:\n                raise ValueError(\"Hatch character must have a cell length of 1\")\n            if isinstance(color, str):\n                color = Color.parse(color)\n            hatch = (character, color)\n\n        obj.set_rule(\"hatch\", hatch)\n","sourceCodeStart":1231,"sourceCodeEnd":1259,"githubUrl":"https://github.com/Textualize/textual/blob/06dbeef4bb70fb718236aa418ed658ef4667a126/src/textual/css/_style_properties.py#L1231-L1259","documentation":"The hatch property accepts either a single character or a named hatch from the HATCHES mapping, paired with a color. When the character portion is not length-1 and not a known hatch name, this ValueError is raised listing what was found. Hatch names are things like 'cross', 'half', 'solid' etc. defined in textual.css.constants.HATCHES.","triggerScenarios":"`styles.hatch = (\"xx\", \"red\")`, `styles.hatch = (\"diaganol\", \"red\")` (typo'd hatch name), or a multi-char string not in HATCHES.","commonSituations":"Misspelling hatch names, passing a full-line fill string, or not realizing a non-single character must be a registered hatch name.","solutions":["Use a single character, e.g. `(\"|\", \"red\")`","Use an exact HATCHES key name (check textual.css.constants.HATCHES)"],"exampleFix":"# before\nstyles.hatch = (\"diaganol\", \"red\")\n# after\nstyles.hatch = (\"\\\\\", \"red\")","handlingStrategy":"validation","validationCode":"from textual.css.constants import HATCHES\nif len(ch) == 1 or ch in HATCHES:\n    styles.hatch = (ch, color)","typeGuard":"def is_valid_hatch_char(ch: str) -> bool:\n    return len(ch) == 1 or ch in HATCHES","tryCatchPattern":null,"preventionTips":["Reference HATCHES keys directly instead of typing hatch names"],"tags":["textual","css","hatch","validation"],"backgroundTag":"invalid-css-value","analyzedSha":"06dbeef4bb70fb718236aa418ed658ef4667a126","analyzedAt":"2026-08-27T02:36:57.214Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}