{"record":{"id":"bc9036cfdad7b4f8","repo":"pola-rs/polars","slug":"unrecognised-deprecation-type-tp-r","errorCode":null,"errorMessage":"unrecognised deprecation type {tp!r}.\n","messagePattern":"unrecognised deprecation type (.+?)\\.\n","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/_utils/deprecation.py","lineNumber":356,"sourceCode":"            )\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\n                results[deprecation_type].extend(func_names)\n\n    return {\n        dep: sorted(results[dep])\n        for dep in sorted(results)\n        if not types or dep in types\n    }\n\n\n__all__ = [\n    \"deprecate_nonkeyword_arguments\",\n    \"deprecate_parameter_as_multi_positional\",\n    \"deprecate_renamed_parameter\",\n    \"deprecated\",\n    \"identify_deprecations\",\n]\n","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/_utils/deprecation.py#L338-L374","documentation":"During its scan, `identify_deprecations` discovers deprecation functions found in source files; if a found function's deprecation_type is not in `valid_types`, it raises this ValueError. It indicates a new deprecation helper was added without updating the DeprecationType alias.","triggerScenarios":"Running `identify_deprecations` after a contributor added a new deprecation-emitting function (e.g. a new warning helper) that is not covered by the DeprecationType type alias.","commonSituations":"Polars maintenance/CI work: a PR introduces a new deprecation mechanism but forgets to extend the type alias, so the self-check fails.","solutions":["Add the new deprecation type to the DeprecationType type alias in deprecation.py","Or update the new helper to emit an already-registered deprecation type","Re-run identify_deprecations to confirm the scan passes"],"exampleFix":"// before\nDeprecationType = Literal[\"function\", \"parameter\"]\n// after\nDeprecationType = Literal[\"function\", \"parameter\", \"sibling\"]","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    results = identify_deprecations(types=valid_types)\nexcept ValueError as e:\n    raise RuntimeError(\"new deprecation function must be added to DeprecationType\") from e","preventionTips":["When adding a new deprecation helper, extend the DeprecationType Literal in the same PR","Run identify_deprecations in CI to catch new unregistered deprecation functions early"],"tags":["python","polars","developer-tooling","internal-invariant"],"backgroundTag":"internal-invariant-violation","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"}