{"record":{"id":"8ffad62d471e849d","repo":"pola-rs/polars","slug":"invalid-table-format-name-format-r-nexpected-one-of-join","errorCode":null,"errorMessage":"invalid table format name: {format!r}\\nExpected one of: {', '.join(valid_format_names)}","messagePattern":"invalid table format name: (.+?)\\\\nExpected one of: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/config.py","lineNumber":1227,"sourceCode":"        ...     print(df)\n        | abc  | mno   | xyz   |\n        |------|-------|-------|\n        | -2.5 | hello | true  |\n        | 5.0  | world | false |\n\n        Raises\n        ------\n        ValueError: if format string not recognised.\n        \"\"\"\n        # note: can see what the different styles look like in the comfy-table tests\n        # https://github.com/Nukesor/comfy-table/blob/main/tests/all/presets_test.rs\n        if format is None:\n            os.environ.pop(\"POLARS_FMT_TABLE_FORMATTING\", None)\n        else:\n            valid_format_names = get_args(TableFormatNames)\n            if (format_upper := format.upper()) not in valid_format_names:\n                msg = f\"invalid table format name: {format!r}\\nExpected one of: {', '.join(valid_format_names)}\"\n                raise ValueError(msg)\n            os.environ[\"POLARS_FMT_TABLE_FORMATTING\"] = format_upper\n        plr.config_reload_env_var(\"POLARS_FMT_TABLE_FORMATTING\")\n\n        if rounded_corners is None:\n            os.environ.pop(\"POLARS_FMT_TABLE_ROUNDED_CORNERS\", None)\n        else:\n            os.environ[\"POLARS_FMT_TABLE_ROUNDED_CORNERS\"] = str(int(rounded_corners))\n        plr.config_reload_env_var(\"POLARS_FMT_TABLE_ROUNDED_CORNERS\")\n\n        return cls\n\n    @classmethod\n    def set_tbl_hide_column_data_types(cls, active: bool | None = True) -> type[Config]:\n        \"\"\"\n        Hide table column data types (i64, f64, str etc.).\n\n        Examples\n        --------","sourceCodeStart":1209,"sourceCodeEnd":1245,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/config.py#L1209-L1245","documentation":"Config.set_tbl_formatting validates the table style name against the TableFormatNames Literal (via typing.get_args) before storing it in POLARS_FMT_TABLE_FORMATTING. An unrecognized name raises a ValueError listing all valid names. None resets the setting.","triggerScenarios":"pl.Config.set_tbl_formatting('fancy_grid') or any string not in the valid TableFormatNames set (e.g. 'ASCII_FULL', 'UTF8_FULL', etc.).","commonSituations":"Copying table style names from the rich library or other DataFrame libs whose style vocabularies differ; guessing a style name instead of reading the error's 'Expected one of:' list.","solutions":["Use a name from the error message's 'Expected one of:' list (e.g. 'ASCII_FULL', 'UTF8_FULL').","Pass None to reset formatting to default.","Import TableFormatNames and check membership before calling."],"exampleFix":"// before\npl.Config.set_tbl_formatting(\"fancy_grid\")\n// after\npl.Config.set_tbl_formatting(\"UTF8_FULL\")","handlingStrategy":"validation","validationCode":"from typing import get_args\nfrom polars.datatypes import TableFormatNames  # or import from its module\nvalid = get_args(TableFormatNames)\nif fmt is not None and fmt.upper() not in valid:\n    raise ValueError(f\"fmt must be one of {valid}\")\npl.Config.set_tbl_formatting(fmt)","typeGuard":"def is_valid_table_format(v, valid) -> bool:\n    return v is None or (isinstance(v, str) and v.upper() in valid)","tryCatchPattern":"try:\n    pl.Config.set_tbl_formatting(fmt)\nexcept ValueError as e:\n    print(e)  # message lists all valid names\n    pl.Config.set_tbl_formatting(None)","preventionTips":["Copy a valid style name from the error message's 'Expected one of:' list.","Do not reuse table style names from rich/tabulate.","Centralize table style choice in one config constant."],"tags":["python","polars","config","invalid-enum-value"],"backgroundTag":"invalid-enum-value","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}