{"record":{"id":"05dc41ffdbfd83c9","repo":"pandas-dev/pandas","slug":"value-must-be-one-of-pp-values","errorCode":null,"errorMessage":"Value must be one of {pp_values}","messagePattern":"Value must be one of (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pandas/_config/config.py","lineNumber":902,"sourceCode":"        if not isinstance(x, _type):\n            raise ValueError(f\"Value must be an instance of {type_repr}\")\n\n    return inner\n\n\ndef is_one_of_factory(legal_values: Sequence) -> Callable[[Any], None]:\n    callables = [c for c in legal_values if callable(c)]\n    legal_values = [c for c in legal_values if not callable(c)]\n\n    def inner(x: object) -> None:\n        if x not in legal_values:\n            if not any(c(x) for c in callables):\n                uvals = [str(lval) for lval in legal_values]\n                pp_values = \"|\".join(uvals)\n                msg = f\"Value must be one of {pp_values}\"\n                if len(callables):\n                    msg += \" or a callable\"\n                raise ValueError(msg)\n\n    return inner\n\n\ndef is_nonnegative_int(value: object) -> None:\n    \"\"\"\n    Verify that value is None or a positive int.\n\n    Parameters\n    ----------\n    value : None or int\n            The `value` to be checked.\n\n    Raises\n    ------\n    ValueError\n        When the value is not None or is a negative integer\n    \"\"\"","sourceCodeStart":884,"sourceCodeEnd":920,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/_config/config.py#L884-L920","documentation":"Raised by `is_one_of_factory` when an option value is not in the enumerated legal values and also fails any predicate callables in the validator. pandas registers enum-style options (e.g. string scalers, plotting backends, styler renderers) with this factory. The message lists the legal values joined by `|`, and appends `or a callable` if the validator accepts callable predicates (used by options like `plotting.backend` or `display.html.table_schema`).","triggerScenarios":"`pd.set_option('plotting.backend', 'seaborn')` when seaborn isn't a registered backend; `pd.set_option('display.float_format', 'comma')` (string where a callable is required); `pd.set_option('mode.copy_on_write', 'yes')` instead of a legal value.","commonSituations":"Guessing an option value from memory instead of checking `describe_option`; passing a string when a callable is expected (float_format); version skew where a value was renamed/removed between pandas releases.","solutions":["Run `pd.describe_option('<name>')` and copy a value verbatim from the listed legal values.","For callable-accepting options, pass the function object, not its name as a string.","If the value legitimately should be allowed, register it through the documented public API rather than bypassing the validator."],"exampleFix":"// before\npd.set_option('display.float_format', 'comma')\n\n// after\npd.set_option('display.float_format', lambda v: f'{v:,.2f}')","handlingStrategy":"validation","validationCode":"import pandas as pd\ndoc = pd.describe_option(name)  # human-readable list of legal values\nassert str(value) in doc or callable(value)","typeGuard":null,"tryCatchPattern":"try:\n    pd.set_option(name, value)\nexcept ValueError:\n    # revert to default and warn\n    pd.reset_option(name)","preventionTips":["Keep an enum/constant for each option's legal values in your config layer.","Never pass a string where a callable is documented."],"tags":["config","enum-validation","set-option"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}