pola-rs/polars · error · AttributeError

`Config` has no option {opt!r}

Error message

`Config` has no option {opt!r}

What it means

`pl.Config.set(**options)` (and `Config(**options)`) dispatches each keyword to a `Config.set_<name>` method: `_set_config_params` first tries the option name as an attribute, then retries with a `set_` prefix. If neither exists it raises `AttributeError: \"'Config' has no option ...\"`, meaning the option name is not a real Config option in your polars version.

Source

Thrown at py-polars/src/polars/config.py:386

        self._original_runtime_state = None

    def __eq__(self, other: object) -> bool:
        if not isinstance(other, Config):
            return False
        return (self._original_state == other._original_state) and (
            self._context_options == other._context_options
        )

    def __ne__(self, other: object) -> bool:
        return not self.__eq__(other)

    def _set_config_params(self, **options: Unpack[ConfigParameters]) -> None:
        for opt, value in options.items():
            if not hasattr(self, opt) and not opt.startswith("set_"):
                opt = f"set_{opt}"
            if not hasattr(self, opt):
                msg = f"`Config` has no option {opt!r}"
                raise AttributeError(msg)
            getattr(self, opt)(value)

    @classmethod
    def load(cls, cfg: str) -> Config:
        """
        Load (and set) previously saved Config options from a JSON string.

        Parameters
        ----------
        cfg : str
            JSON string produced by `Config.save()`.

        See Also
        --------
        load_from_file : Load (and set) Config options from a JSON file.
        save : Save the current set of Config options as a JSON string or file.
        """
        try:

View on GitHub (pinned to 68506541d2)

Solutions

  1. List the real options and use the exact name: `[n for n in dir(pl.Config) if n.startswith('set_')]`.
  2. If it worked on an older polars, check the changelog for renames/removals and update the name.
  3. If the option has no Config method, set the `POLARS_*` environment variable directly and call `pl.Config.reload_env_vars()`.

Example fix

# before
pl.Config.set(tbl_formating="ASCII_FULL")  # AttributeError: 'Config' has no option 'set_tbl_formating'

# after
pl.Config.set_tbl_formatting("ASCII_FULL")
Defensive patterns

Strategy: validation

Validate before calling

def safe_config_set(cfg: type, **options) -> None:
    for opt, value in options.items():
        attr = opt if hasattr(cfg, opt) else (f"set_{opt}" if hasattr(cfg, f"set_{opt}") else None)
        if attr is None:
            raise AttributeError(
                f"unknown Config option {opt!r}; valid: "
                f"{[n[4:] for n in dir(cfg) if n.startswith('set_')]}"
            )
        getattr(cfg, attr)(value)

safe_config_set(pl.Config, tbl_formatting="ASCII_FULL")

Try / catch

try:
    pl.Config.set(**user_options)
except AttributeError as err:
    bad = err.args[0].split("option ")[-1].strip("'")
    logging.warning("skipping unknown Config option %r", bad)
    pl.Config.set(**{k: v for k, v in user_options.items() if f"{k!r}" not in err.args[0]})

Prevention

When it happens

Trigger: `pl.Config.set(tbl_formating='ASCII_FULL')` (typo); passing an option that only exists as a POLARS_* env var with no Config method; using an option that was renamed or removed in a different polars version.

Common situations: Copy-pasting Config snippets between polars versions where option names changed; typos in kwargs; assuming every POLARS_* environment variable has a Config setter.

Related errors


AI-assisted analysis of pola-rs/polars@68506541d2 (2026-08-19). Data as JSON: /api/errors/08a8cea5f61f28c4. Report an issue: GitHub.