{"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/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/_config/config.py#L420-L456","documentation":"Raised by DictWrapper.__getattr__ (config.py:437-438) when the requested attribute key is not present in the underlying nested dict. Chained from the internal KeyError. OptionError subclasses AttributeError, so hasattr/getattr semantics work as expected.","triggerScenarios":"pd.options.context (no such attribute) or pd.options.display.nonexistent.","commonSituations":"Accessing a typo'd or removed option via attribute syntax; using getattr-style introspection on a namespace that does not contain the leaf.","solutions":["List valid attributes via dir(pd.options.display) or pd.describe_option('display').","Use the function API pd.get_option('display.x') with try/except OptionError.","Catch AttributeError (OptionError is a subclass) for optional-option handling."],"exampleFix":"# before\npd.options.display.context  # OptionError: No such option\n\n# after\npd.options.display.max_columns  # an existing leaf","handlingStrategy":"type-guard","validationCode":"def get_attr_option(root, key, default=None):\n    d = object.__getattribute__(root, 'd')\n    if key not in d:\n        return default\n    return getattr(root, key)","typeGuard":"def has_option_attr(root, key: str) -> bool:\n    d = object.__getattribute__(root, 'd')\n    return key in d","tryCatchPattern":"from pandas.errors import OptionError\ntry:\n    val = getattr(pd.options.display, key)\nexcept OptionError:\n    val = None","preventionTips":["Use dir(pd.options.<namespace>) to enumerate valid attributes.","Treat OptionError as AttributeError (it is one) for hasattr-style checks.","Prefer the function API pd.get_option for user-facing option names."],"tags":["config","options-attribute","getattr"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}