pola-rs/polars · error · AttributeError
`Config` has no option
Error message
`Config` has no option {opt!r} What it means
Raised when Config._set_config_params receives an option name that does not correspond to any attribute/method on the Config class (after trying the set_ prefix). Polars Config options are exposed as set_* methods, so an unknown name is an AttributeError.
Solutions
- Check the exact option name against polars.Config docs (e.g. set_tbl_cell_max_length not tbl_cell_max_length)
- Remove the unknown key from the saved JSON config string
- Upgrade/downgrade polars so the option exists
- Use getattr to probe availability: hasattr(polars.Config, 'set_' + name) before calling
Example fix
// before pl.Config(tblx_cell_max_length=20) # AttributeError // after pl.Config(tbl_cell_max_length=20)
Defensive patterns
Strategy: validation
Validate before calling
opt = 'tbl_cell_max_length'
if not hasattr(pl.Config, f'set_{opt}'):
raise ValueError(f'unknown Config option: {opt}') Type guard
def is_valid_config_option(name: str) -> bool:
return hasattr(pl.Config, name) or hasattr(pl.Config, f'set_{name}') Try / catch
try:
pl.Config(**opts)
except AttributeError as e:
logging.error('bad config option: %s', e)
raise Prevention
- Copy option names from current polars.Config docs
- Version-pin polars when loading saved configs
- Strip unknown keys from saved JSON before load
When it happens
Trigger: Config(...some_option=...) or Config.load() with a JSON containing an unknown environment option — e.g. a typo like 'tblx_cell_max_length' or an option removed in a newer polars version.
Common situations: Typo'd keyword argument to Config(); loading a saved config saved from an older polars version whose option names changed; passing names without their set_ equivalents when the attribute check fails.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Altair has no method 'mark_
- {credential_provider}
- invalid alignment
- invalid Config file (did you mean to use `load`?)
- invalid Config file (did you mean to use `load`?)\n
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/08a8cea5f61f28c4.
Report an issue: GitHub.
Appendix: 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 fe841f959e)