{"record":{"id":"4c59d6a9c629afdf","repo":"pola-rs/polars","slug":"func-name-r-received-both-param-name-r-and-pa","errorCode":null,"errorMessage":"{func_name!r} received both {param.name!r} and {param.new_name!r} as arguments; {param.name!r}{was_deprecated_and} has been renamed to {param.new_name!r} in version {param.removed_in}.","messagePattern":"(.+?) received both (.+?) and (.+?) as arguments; (.+?)(.+?) has been renamed to (.+?) in version (.+?)\\.","errorType":"exception","errorClass":"ArgumentRemovedError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/_utils/expired.py","lineNumber":143,"sourceCode":"def _raise_removed_argument_error(\n    param: RemovedParameter | RenamedParameter,\n    *,\n    func_name: str,\n    kwargs: dict[str, object],\n) -> NoReturn:\n    was_deprecated_and = (\n        f\" was deprecated in version {param.deprecated_in} and\"\n        if param.deprecated_in is not None\n        else \"\"\n    )\n    if isinstance(param, RenamedParameter):\n        if param.name in kwargs and param.new_name in kwargs:\n            msg = (\n                f\"{func_name!r} received both {param.name!r} and {param.new_name!r} as arguments;\"\n                f\" {param.name!r}{was_deprecated_and} has been renamed to\"\n                f\" {param.new_name!r} in version {param.removed_in}.\"\n            )\n            raise ArgumentRemovedError(msg)\n        else:\n            msg = (\n                f\"the argument {param.name!r} for {func_name!r}{was_deprecated_and}\"\n                f\" has been removed in version {param.removed_in}.\"\n                f\" It was renamed to {param.new_name!r}.\"\n            )\n            msg = msg if param.hint is None else f\"{msg} {param.hint}\"\n            raise ArgumentRemovedError(msg)\n    elif isinstance(param, RemovedParameter):\n        msg = (\n            f\"the argument {param.name!r} for {func_name!r}{was_deprecated_and}\"\n            f\" has been removed in version {param.removed_in}.\"\n        )\n        msg = msg if param.hint is None else f\"{msg} {param.hint}\"\n        raise ArgumentRemovedError(msg)\n    else:\n        msg = f\"Unexpected parameter type: {type(param)!r}\"\n        raise TypeError(msg)","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/_utils/expired.py#L125-L161","documentation":"When a function decorated with `removed_parameters` receives both the removed (old) parameter name and its renamed replacement as keyword arguments, Polars raises ArgumentRemovedError immediately instead of guessing which value applies.","triggerScenarios":"Calling a decorated function with the old kwarg and the new kwarg simultaneously, e.g. `func(x=1, x_new=2)`, after the parameter was renamed in the removal version.","commonSituations":"Half-migrated code after a Polars upgrade; wrappers that merge user kwargs with defaults containing the new name while forwarding the old name; generated code mixing API generations.","solutions":["Pass only the new parameter name","Remove the old-name kwarg from all call sites and wrappers","Ensure library code no longer injects the new name as a default when forwarding legacy kwargs"],"exampleFix":"// before\npl.read_csv(f, row_count_name=\"n\", row_index_name=\"idx\")\n// after\npl.read_csv(f, row_index_name=\"idx\")","handlingStrategy":"try-catch","validationCode":"if old_name in kwargs and new_name in kwargs:\n    raise ValueError(f\"pass either {old_name!r} or {new_name!r}, not both\")","typeGuard":null,"tryCatchPattern":"try:\n    result = func(**kwargs)\nexcept ArgumentRemovedError as e:\n    kwargs.pop(old_name, None)\n    result = func(**kwargs)","preventionTips":["During migrations, remove the old kwarg everywhere in one pass","Avoid wrappers that merge defaults containing the new name with user-supplied legacy kwargs","Treat ArgumentRemovedError as a code bug, not a runtime condition"],"tags":["python","polars","removed-argument","keyword-arguments"],"backgroundTag":"deprecated-api-usage","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"}