{"record":{"id":"6dbc66177ee46c94","repo":"pandas-dev/pandas","slug":"option-key-is-a-reserved-key","errorCode":null,"errorMessage":"Option '{key}' is a reserved key","messagePattern":"Option '(.+?)' is a reserved key","errorType":"exception","errorClass":"OptionError","httpStatus":null,"severity":"error","filePath":"pandas/_config/config.py","lineNumber":563,"sourceCode":"    cb\n        a function of a single argument \"key\", which is called\n        immediately after an option value is set/reset. key is\n        the full name of the option.\n\n    Raises\n    ------\n    ValueError if `validator` is specified and `defval` is not a valid value.\n\n    \"\"\"\n    import keyword\n    import tokenize\n\n    key = key.lower()\n\n    if key in _registered_options:\n        raise OptionError(f\"Option '{key}' has already been registered\")\n    if key in _reserved_keys:\n        raise OptionError(f\"Option '{key}' is a reserved key\")\n\n    # the default value should be legal\n    if validator:\n        validator(defval)\n\n    # walk the nested dict, creating dicts as needed along the path\n    path = key.split(\".\")\n\n    for k in path:\n        if not re.match(\"^\" + tokenize.Name + \"$\", k):\n            raise ValueError(f\"{k} is not a valid identifier\")\n        if keyword.iskeyword(k):\n            raise ValueError(f\"{k} is a python keyword\")\n\n    cursor = _global_config\n    msg = \"Path prefix to option '{option}' is already an option\"\n\n    for i, p in enumerate(path[:-1]):","sourceCodeStart":545,"sourceCodeEnd":581,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/_config/config.py#L545-L581","documentation":"Raised by register_option (config.py:562-563) when the key is in _reserved_keys, which currently contains only 'all'. Reserved keys have special meaning in the config API and cannot be reused.","triggerScenarios":"cf.register_option('all', True) — 'all' is reserved because reset_option('all') resets every option.","commonSituations":"Picking a short, generic option name that collides with the reserved vocabulary.","solutions":["Pick a namespaced key like 'mylib.all' instead of bare 'all'.","Check cf._reserved_keys before registering to surface the conflict early.","Avoid top-level reserved words when designing an option namespace."],"exampleFix":"# before\nimport pandas._config.config as cf\ncf.register_option('all', True)  # reserved key\n\n# after\ncf.register_option('myapp.all', True)","handlingStrategy":"validation","validationCode":"import pandas._config.config as cf\ndef safe_register(key, defval, **kw):\n    if key.lower() in cf._reserved_keys:\n        raise ValueError(f'{key!r} is reserved; pick a different name')\n    cf.register_option(key, defval, **kw)","typeGuard":"def is_reserved(key: str) -> bool:\n    import pandas._config.config as cf\n    return key.lower() in cf._reserved_keys","tryCatchPattern":null,"preventionTips":["Namespace every custom option under a library prefix (e.g. 'myapp.').","Avoid bare generic words like 'all' as option names.","Check cf._reserved_keys at design time."],"tags":["config","register-option","reserved"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}