{"record":{"id":"a7573124bcbded5d","repo":"pola-rs/polars","slug":"invalid-table-format-name-format-r-expected-one","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":"ValueError","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/68506541d2de983056c9eb244e1ea05fab377dfc/py-polars/src/polars/config.py#L1209-L1245","documentation":"`pl.Config.set_tbl_formatting(format)` validates the preset name against `TableFormatNames`, the comfy-table presets polars exposes (ASCII_FULL, ASCII_BORDERS_ONLY, ASCII_CONDENSED, UTF8_FULL, UTF8_NO_BORDERS, etc.). Unknown names raise ValueError, and the message helpfully lists every valid name.","triggerScenarios":"`pl.Config.set_tbl_formatting('pretty')`, 'grid', 'markdown', 'psql' (a tabulate name, not a polars preset), or a preset name removed/renamed in another polars version.","commonSituations":"Guessing format names by analogy with other table libraries (tabulate/prettytable); version drift after upgrading polars; typos in lowercase names (upper-cased for you, so case is not the issue).","solutions":["Read the valid names straight from the error message — it prints the full list.","In code: `import typing; from polars._typing import TableFormatNames; typing.get_args(TableFormatNames)`.","Check the polars changelog if a name that used to work now fails."],"exampleFix":"# before\npl.Config.set_tbl_formatting(\"markdown\")  # ValueError: invalid table format name\n\n# after\npl.Config.set_tbl_formatting(\"ASCII_MARKDOWN\")","handlingStrategy":"validation","validationCode":"import typing\nfrom polars._typing import TableFormatNames\n\nVALID_FORMATS = frozenset(typing.get_args(TableFormatNames))\n\ndef set_table_format(fmt: str | None) -> None:\n    if fmt is not None and fmt.upper() not in VALID_FORMATS:\n        raise ValueError(f\"format must be one of {sorted(VALID_FORMATS)}, got {fmt!r}\")\n    pl.Config.set_tbl_formatting(fmt)","typeGuard":"import typing\nfrom polars._typing import TableFormatNames\n\ndef is_table_format_name(value: str) -> bool:\n    return value.upper() in typing.get_args(TableFormatNames)","tryCatchPattern":null,"preventionTips":["Derive the valid names from TableFormatNames instead of hard-coding them, so upgrades stay in sync.","Expose format choice as an enum in your app and validate at the boundary."],"tags":["config","table-display","formatting","validation","polars"],"backgroundTag":"invalid-argument-value","analyzedSha":"68506541d2de983056c9eb244e1ea05fab377dfc","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}