pola-rs/polars · error
Unexpected parameter type
Error message
Unexpected parameter type: {type(param)!r} What it means
`_raise_removed_argument_error` ends with a catch-all TypeError for any parameter object that is neither RenamedParameter nor RemovedParameter. Hitting it means the expired-parameter machinery was wired up with an unsupported parameter descriptor type.
Solutions
- Fix the descriptor construction to pass a RenamedParameter or RemovedParameter instance
- Add a branch for the new parameter type in `_raise_removed_argument_error`
- Verify the decorator is imported from the right module (no shadowing of the parameter classes)
Example fix
// before
params = [("old", "new", "0.19")] # raw tuples
// after
params = [RenamedParameter(name="old", new_name="new", removed_in="0.19")] Defensive patterns
Strategy: try-catch
Validate before calling
assert isinstance(param, (RenamedParameter, RemovedParameter)), f"bad param descriptor: {type(param)!r}" Type guard
def is_valid_removed_param(p: object) -> TypeGuard[RenamedParameter | RemovedParameter]:
from polars._utils.expired import RenamedParameter, RemovedParameter
return isinstance(p, (RenamedParameter, RemovedParameter)) Try / catch
try:
result = func(...)
except TypeError as e:
if "Unexpected parameter type" in str(e):
raise RuntimeError("polars internals misconfigured; report upstream") from e
raise Prevention
- Only construct descriptors via the public removed_parameters/renamed_parameters helpers
- Add isinstance checks/tests when introducing new parameter descriptor types
- Avoid shadowing the RenamedParameter/RemovedParameter imports
When it happens
Trigger: A Polars developer passes an unexpected object (wrong class or a misconstructed descriptor) to the removed-parameters decorator helper; not reachable through normal user API calls.
Common situations: Polars maintenance: refactoring the deprecation/expired utilities and forgetting to add a branch for a new parameter descriptor type.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- unrecognised deprecation type
- accessing ` ` from the top-level `polars` module was…
- altair>=5.4.0 is required for `.plot`
- `arctan2` expected a `str` or `Expr` got a
- `arctan2` expected a `str` or `Expr` got a
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/82f4eb4f1a2d825d.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/_utils/expired.py:161
raise ArgumentRemovedError(msg)
else:
msg = (
f"the argument {param.name!r} for {func_name!r}{was_deprecated_and}"
f" has been removed in version {param.removed_in}."
f" It was renamed to {param.new_name!r}."
)
msg = msg if param.hint is None else f"{msg} {param.hint}"
raise ArgumentRemovedError(msg)
elif isinstance(param, RemovedParameter):
msg = (
f"the argument {param.name!r} for {func_name!r}{was_deprecated_and}"
f" has been removed in version {param.removed_in}."
)
msg = msg if param.hint is None else f"{msg} {param.hint}"
raise ArgumentRemovedError(msg)
else:
msg = f"Unexpected parameter type: {type(param)!r}"
raise TypeError(msg)
View on GitHub (pinned to fe841f959e)