{"record":{"id":"29c80977ecbe766d","repo":"pola-rs/polars","slug":"unrecognised-deprecation-type-tp-r-expected-one-or-more-of","errorCode":null,"errorMessage":"unrecognised deprecation type {tp!r}.\nExpected one (or more) of {repr(sorted(valid_types))[1:-1]}","messagePattern":"unrecognised deprecation type (.+?)\\.\nExpected one \\(or more\\) of (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/_utils/deprecation.py","lineNumber":339,"sourceCode":"            - \"function\"\n            - \"renamed_parameter\"\n            - \"nonkeyword_arguments\"\n            - \"parameter_as_multi_positional\"\n\n    Examples\n    --------\n    >>> from polars._utils.deprecation import identify_deprecations\n    >>> identify_deprecations(\"nonkeyword_arguments\")  # doctest: +IGNORE_RESULT\n    {'nonkeyword_arguments': ['functions.business.business_day_count']}\n    \"\"\"\n    valid_types = set(get_args(DeprecationType))\n    for tp in types:\n        if tp not in valid_types:\n            msg = (\n                f\"unrecognised deprecation type {tp!r}.\\n\"\n                f\"Expected one (or more) of {repr(sorted(valid_types))[1:-1]}\"\n            )\n            raise ValueError(msg)\n\n    package_path = Path(sys.modules[\"polars\"].__file__).parent  # type: ignore[arg-type]\n    results = defaultdict(list)\n\n    for py_file in package_path.rglob(\"*.py\"):\n        rel_path = py_file.relative_to(package_path)\n        module_path = \".\".join(rel_path.parts).removesuffix(\".py\")\n        with py_file.open(\"r\", encoding=\"utf-8\") as src:\n            for deprecation_type, func_names in _find_deprecated_functions(\n                source=src.read(),\n                module_path=module_path,\n            ).items():\n                if deprecation_type not in valid_types:\n                    # note: raising here implies we have a new deprecation function\n                    # that should be added to the DeprecationType type alias\n                    msg = f\"unrecognised deprecation type {tp!r}.\\n\"\n                    raise ValueError(msg)\n","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/_utils/deprecation.py#L321-L357","documentation":"`identify_deprecations` is a polars developer utility that scans the package for deprecation markers. It raises this ValueError when an element of the `types` argument is not one of the valid DeprecationType values.","triggerScenarios":"Running `polars._utils.deprecation.identify_deprecations(types=[...])` with an unrecognized type string, e.g. `types=['renamed_arg']` when valid types are things like 'function', 'parameter', 'method', 'attribute', 'classmethod', etc.","commonSituations":"Maintainer tooling invocations with a mistyped or newly-invented deprecation category; automated scripts written against an older list of valid types.","solutions":["Pass only types from the valid DeprecationType set (listed in the error message)","Check the DeprecationType type alias in deprecation.py for the exact valid values","Fix typos in the types argument"],"exampleFix":"// before\nidentify_deprecations(types=[\"removed_params\"])\n// after\nidentify_deprecations(types=[\"parameter\", \"function\"])","handlingStrategy":"validation","validationCode":"from polars._utils.deprecation import identify_deprecations, DeprecationType\nimport typing\nvalid = set(typing.get_args(DeprecationType))\nassert set(types) <= valid, f\"bad types: {set(types) - valid}\"","typeGuard":"def is_deprecation_type(t: object) -> TypeGuard[str]:\n    import typing\n    from polars._utils.deprecation import DeprecationType\n    return t in set(typing.get_args(DeprecationType))","tryCatchPattern":"try:\n    results = identify_deprecations(types=types)\nexcept ValueError as e:\n    print(e)  # lists valid types\n    results = identify_deprecations(types=[t for t in types if is_deprecation_type(t)])","preventionTips":["Derive the types list from typing.get_args(DeprecationType) rather than hardcoding","Keep maintainer scripts in sync with the polars version under test"],"tags":["python","polars","developer-tooling","validation"],"backgroundTag":"invalid-enum-argument","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}