{"record":{"id":"763cf531ea3efbf0","repo":"Textualize/textual","slug":"expected-a-str-path-or-list-str-path-for-the-c","errorCode":null,"errorMessage":"Expected a str, Path or list[str | Path] for the CSS_PATH.","messagePattern":"Expected a str, Path or list\\[str \\| Path\\] for the CSS_PATH\\.","errorType":"validation","errorClass":"CSSPathError","httpStatus":null,"severity":"error","filePath":"src/textual/_path.py","lineNumber":42,"sourceCode":"    Args:\n        css_path: Value to be normalized.\n\n    Raises:\n        CSSPathError: If the argument has the wrong format.\n\n    Returns:\n        A list of paths.\n    \"\"\"\n\n    paths: list[PurePath] = []\n    if isinstance(css_path, str):\n        paths = [Path(css_path)]\n    elif isinstance(css_path, PurePath):\n        paths = [css_path]\n    elif isinstance(css_path, list):\n        paths = [Path(path) for path in css_path]\n    else:\n        raise CSSPathError(\"Expected a str, Path or list[str | Path] for the CSS_PATH.\")\n\n    return paths\n\n\ndef _make_path_object_relative(path: str | PurePath, obj: object) -> Path:\n    \"\"\"Convert the supplied path to a Path object that is relative to a given Python object.\n    If the supplied path is absolute, it will simply be converted to a Path object.\n    Used, for example, to return the path of a CSS file relative to a Textual App instance.\n\n    Args:\n        path: A path.\n        obj: A Python object to resolve the path relative to.\n\n    Returns:\n        A resolved Path object, relative to obj\n    \"\"\"\n    path = Path(path)\n","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/Textualize/textual/blob/06dbeef4bb70fb718236aa418ed658ef4667a126/src/textual/_path.py#L24-L60","documentation":"CSSPathError raised by textual's CSS path normalization when the CSS_PATH class variable is not a str, Path/PurePath, or a list of those. The App constructor validates CSS_PATH before mounting.","triggerScenarios":"Setting CSS_PATH = ('app.css', 'extra.css') (a tuple), a set, None, or a dict on an App subclass and then running it.","commonSituations":"Developers switch from list to tuple literal, refactor CSS_PATH dynamically, or copy-paste configs from other frameworks expecting different types.","solutions":["Use a plain string CSS_PATH = \"app.css\" or a Path object","If multiple stylesheets, use an explicit list: CSS_PATH = [\"a.css\", \"b.css\"]","Convert other iterables to list before assigning: CSS_PATH = list(paths)"],"exampleFix":"# before\nclass MyApp(App):\n    CSS_PATH = (\"app.css\", \"extra.css\")\n\n# after\nclass MyApp(App):\n    CSS_PATH = [\"app.css\", \"extra.css\"]","handlingStrategy":"type-guard","validationCode":"from pathlib import Path\ncss = ('app.css', 'extra.css')\nassert isinstance(css, (str, Path, list)), 'CSS_PATH must be str/Path/list'","typeGuard":"def valid_css_path(p) -> bool:\n    import pathlib\n    return isinstance(p, (str, pathlib.Path, pathlib.PurePath)) or (\n        isinstance(p, list) and all(isinstance(x, (str, pathlib.Path)) for x in p)\n    )","tryCatchPattern":"try:\n    app.run()\nexcept CSSPathError:\n    app.CSS_PATH = [str(p) for p in app.CSS_PATH]  # then retry","preventionTips":["Always write CSS_PATH as a string or explicit list","Run the app once in CI to catch class-definition-time issues"],"tags":["css","config","type-validation","textual"],"backgroundTag":"invalid-config-type","analyzedSha":"06dbeef4bb70fb718236aa418ed658ef4667a126","analyzedAt":"2026-08-27T02:36:57.214Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}