reflex-dev/reflex · error · TypeError
`@rx.memo` does not support positional-only parameters in `{
Error message
`@rx.memo` does not support positional-only parameters in `{fn_name}`. What it means
`@rx.memo` rejects positional-only parameters (those before a `/` in the signature). Memo props are always passed by keyword at the call site, and positional-only names cannot participate in that binding convention, so the signature is rejected at decoration time.
Source
Thrown at packages/reflex-base/src/reflex_base/components/memo.py:1365
"""Reject Python parameter kinds (``*args`` / ``**kwargs`` / positional-only)
that memo does not support.
Args:
parameter: The parameter to check.
fn_name: The function name for error messages.
Raises:
TypeError: If the parameter uses an unsupported kind.
"""
if parameter.kind is inspect.Parameter.VAR_POSITIONAL:
msg = f"`@rx.memo` does not support `*args` in `{fn_name}`."
raise TypeError(msg)
if parameter.kind is inspect.Parameter.VAR_KEYWORD:
msg = f"`@rx.memo` does not support `**kwargs` in `{fn_name}`."
raise TypeError(msg)
if parameter.kind is inspect.Parameter.POSITIONAL_ONLY:
msg = f"`@rx.memo` does not support positional-only parameters in `{fn_name}`."
raise TypeError(msg)
def _classify_parameter(
annotation: Any, param_name: str, fn_name: str
) -> tuple[MemoParamKind, Any]:
"""Walk ``_CLASSIFICATION_ORDER`` and return the first matching kind.
Args:
annotation: The parameter annotation.
param_name: The parameter name (some kinds care, e.g. ``children``).
fn_name: The function name for error messages.
Returns:
The matched ``(kind, kind_data)``.
Raises:
TypeError: If no kind matches.
"""View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Remove the `/` marker so all parameters are normal positional-or-keyword parameters.
- Annotate each parameter as `rx.Var[...]` or `rx.RestProp` and pass props by keyword when calling the memo.
Example fix
# before
@rx.memo
def item(value, /):
return rx.text(value)
# after
@rx.memo
def item(value: rx.Var[str]):
return rx.text(value) Defensive patterns
Strategy: validation
Validate before calling
import inspect
def memo_signature_ok(fn) -> bool:
return all(
p.kind is not inspect.Parameter.POSITIONAL_ONLY
for p in inspect.signature(fn).parameters.values()
) Prevention
- Never use the `/` positional-only marker in memo signatures.
- Write memo params as ordinary positional-or-keyword parameters annotated with rx.Var[...].
When it happens
Trigger: Decorating a function with `@rx.memo` that uses the `/` positional-only marker, e.g. `@rx.memo def item(x, /, y: rx.Var[str]): ...`, or a lambda/function defined via `inspect` or C extensions with implicit positional-only args.
Common situations: Copying modern Python API signatures that use `/`; using `functools.partial` or wrappers that surface parameters as positional-only; mixing conventions when porting typed APIs into memo components.
Related errors
- `@rx.memo` does not support `*args` in `{fn_name}`.
- `@rx.memo` does not support `**kwargs` in `{fn_name}`.
- All parameters of `{fn_name}` must be annotated as `rx.Var[.
- Component-returning `@rx.memo` `{fn.__name__}` must return a
- `{definition.python_name}` only accepts children positionall
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/1cad98527a6b38c9.
Report an issue: GitHub.