{"record":{"id":"748a38d45b16941d","repo":"pandas-dev/pandas","slug":"no-such-keys-s-pat-r","errorCode":null,"errorMessage":"No such keys(s): {pat!r}","messagePattern":"No such keys\\(s\\): (.+?)","errorType":"exception","errorClass":"OptionError","httpStatus":null,"severity":"error","filePath":"pandas/_config/config.py","lineNumber":132,"sourceCode":"    Examples\n    --------\n    >>> pd.options.context\n    Traceback (most recent call last):\n    OptionError: No such option\n    \"\"\"\n\n    __module__ = \"pandas.errors\"\n\n\n#\n# User API\n\n\ndef _get_single_key(pat: str) -> str:\n    keys = _select_options(pat)\n    if len(keys) == 0:\n        _warn_if_deprecated(pat)\n        raise OptionError(f\"No such keys(s): {pat!r}\")\n    if len(keys) > 1:\n        raise OptionError(\"Pattern matched multiple keys\")\n    key = keys[0]\n\n    _warn_if_deprecated(key)\n\n    key = _translate_key(key)\n\n    return key\n\n\ndef get_option(pat: str) -> Any:\n    \"\"\"\n    Retrieve the value of the specified option.\n\n    This method allows users to query the current value of a given option\n    in the pandas configuration system. Options control various display,\n    performance, and behavior-related settings within pandas.","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/_config/config.py#L114-L150","documentation":"Raised by _get_single_key (pandas/_config/config.py:128-132) when no registered option key matches the pattern. Affects get_option/set_option/get_default_val. OptionError subclasses both AttributeError and KeyError, so existing KeyError handlers remain compatible.","triggerScenarios":"Calling pd.get_option('display.foo') or pd.set_option('nonexistent.option', 1) where the pattern matches zero entries in _registered_options.","commonSituations":"Typo in an option name, using an option that was renamed/removed in a newer pandas version, or copy-pasting an option name from outdated documentation.","solutions":["List valid options with `pd.describe_option()` (no args) and copy the exact fully-qualified name.","Validate the pattern before use: `import pandas._config.config as cf; [k for k in cf._registered_options if 'display' in k]`.","Catch OptionError (it subclasses KeyError/AttributeError) and fall back to a default."],"exampleFix":"# before\npd.get_option('display.max_col')  # No such keys(s): 'display.max_col'\n\n# after\npd.get_option('display.max_columns')","handlingStrategy":"validation","validationCode":"import pandas._config.config as cf\ndef option_exists(pat: str) -> bool:\n    return len(cf._select_options(pat)) == 1\nassert option_exists('display.max_columns'), 'use pd.describe_option() to list valid keys'","typeGuard":"def is_known_option(pat: str) -> bool:\n    import pandas._config.config as cf\n    return len(cf._select_options(pat)) == 1","tryCatchPattern":"from pandas.errors import OptionError\ntry:\n    val = pd.get_option(pat)\nexcept OptionError:\n    val = default_val","preventionTips":["Store frequently used option names in module-level constants.","Call pd.describe_option() once to enumerate valid keys.","Avoid partial pattern matching in production code; use fully-qualified names."],"tags":["config","options","typo","validation"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}