{"record":{"id":"4c99fbba121e89f5","repo":"pandas-dev/pandas","slug":"no-such-option","errorCode":null,"errorMessage":"No such option","messagePattern":"No such option","errorType":"exception","errorClass":"OptionError","httpStatus":null,"severity":"error","filePath":"pandas/_config/config.py","lineNumber":438,"sourceCode":"        if prefix:\n            prefix += \".\"\n        prefix += key\n        # you can't set new keys\n        # can you can't overwrite subtrees\n        if key in self.d and not isinstance(self.d[key], dict):\n            set_option(prefix, val)\n        else:\n            raise OptionError(\"You can only set the value of existing options\")\n\n    def __getattr__(self, key: str) -> Any:\n        prefix = object.__getattribute__(self, \"prefix\")\n        if prefix:\n            prefix += \".\"\n        prefix += key\n        try:\n            v = object.__getattribute__(self, \"d\")[key]\n        except KeyError as err:\n            raise OptionError(\"No such option\") from err\n        if isinstance(v, dict):\n            return DictWrapper(v, prefix)\n        else:\n            return get_option(prefix)\n\n    def __dir__(self) -> list[str]:\n        return list(self.d.keys())\n\n\noptions = DictWrapper(_global_config)\n# DictWrapper defines a custom setattr\nobject.__setattr__(options, \"__module__\", \"pandas\")\n\n#\n# Functions for use by pandas developers, in addition to User - api\n\n\n@contextmanager","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/_config/config.py#L420-L456","documentation":"Raised by `DictWrapper.__getattr__` (the `pd.options.<...>` read API) when the requested attribute is not a key in the current config dict. `OptionError` subclasses both `AttributeError` and `KeyError`, so `hasattr`/`getattr(..., default)` and `except KeyError` both behave correctly.","triggerScenarios":"`pd.options.context`, `pd.options.nonexistent`, or reading any attribute that is not part of the option tree.","commonSituations":"Typo reading an option via attribute access; expecting a method/property on `pd.options` that does not exist; copy-paste from another library's option API.","solutions":["Use `dir(pd.options)` or `pd.describe_option()` to see valid names and read with the exact key.","Prefer the function API `pd.get_option(key)` if you are unsure the key exists.","Guard attribute access with `getattr(pd.options, name, default)`."],"exampleFix":"# before\npd.options.contex   # typo -> OptionError: No such option\n\n# after\npd.options.context   # if that is the intended attribute\n# or safely:\ngetattr(pd.options, 'contex', None)","handlingStrategy":"type-guard","validationCode":"import pandas as pd\ndef safe_option_attr(path: str, default=None):\n    node = pd.options\n    for p in path.split('.'):\n        if not hasattr(node, p):\n            return default\n        node = getattr(node, p)\n    return node","typeGuard":"def option_attr_exists(path: str) -> bool:\n    import pandas as pd\n    node = pd.options\n    for p in path.split('.'):\n        if not hasattr(node, p):\n            return False\n        node = getattr(node, p)\n    return True","tryCatchPattern":"from pandas._config.config import OptionError\ntry:\n    val = getattr(pd.options, name)\nexcept OptionError:\n    # also catch AttributeError/KeyError (OptionError subclasses both)\n    val = default","preventionTips":["Use `getattr(pd.options, name, default)` for defensive reads.","Use `dir(pd.options)` to enumerate valid attribute names.","Prefer `pd.get_option(key)` for dynamic keys."],"tags":["config","options-attribute","typo","option-error"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}