reflex-dev/reflex · error · ComputedVarSignatureError
ComputedVarSignatureError(fget.__name__, signature=str(sign)
Error message
ComputedVarSignatureError(fget.__name__, signature=str(sign))
What it means
ComputedVarSignatureError is raised when the getter function passed to rx.computed/rx.memo has a number of parameters other than exactly one (the state instance).
Source
Thrown at packages/reflex-base/src/reflex_base/vars/base.py:2989
A ComputedVar instance.
Raises:
ValueError: If caching is disabled and an update interval is set.
VarDependencyError: If user supplies dependencies without caching.
ComputedVarSignatureError: If the getter function has more than one argument.
"""
if cache is False and interval is not None:
msg = "Cannot set update interval without caching."
raise ValueError(msg)
if cache is False and (deps is not None or auto_deps is False):
msg = "Cannot track dependencies without caching."
raise VarDependencyError(msg)
if fget is not None:
sign = inspect.signature(fget)
if len(sign.parameters) != 1:
raise ComputedVarSignatureError(fget.__name__, signature=str(sign))
if inspect.iscoroutinefunction(fget):
computed_var_cls = AsyncComputedVar
else:
computed_var_cls = ComputedVar
return computed_var_cls(
fget,
initial_value=initial_value,
cache=cache,
deps=deps,
auto_deps=auto_deps,
interval=interval,
backend=backend,
**kwargs,
)
def wrapper(fget: Callable[[BASE_STATE], Any]) -> ComputedVar:
if inspect.iscoroutinefunction(fget):View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Make the getter take exactly one argument (self for state methods)
- Pass the state explicitly when using rx.computed(fget) outside a class: rx.computed(lambda state: ...)
- Close over extra values instead of taking them as parameters
Example fix
# before rx.computed(lambda: State.count * 2) # after rx.computed(lambda state: state.count * 2)
Defensive patterns
Strategy: type-guard
Validate before calling
import inspect assert len(inspect.signature(fget).parameters) == 1, 'computed var getter takes exactly one arg (state)'
Type guard
def is_valid_getter(f) -> bool:
import inspect
return callable(f) and len(inspect.signature(f).parameters) == 1 Prevention
- Always define computed vars as methods on a State subclass taking only self
- Lint new computed vars in CI with a signature check
When it happens
Trigger: Passing a zero-arg lambda or a multi-arg function: rx.computed(lambda: ...) or def f(self, x): ... used as a computed var getter.
Common situations: Using a plain function instead of a method on a State class, or converting a helper function with extra parameters into a computed var.
Related errors
- No default value or factory provided.
- `@rx.memo` does not support `*args` in `{fn_name}`.
- `@rx.memo` does not support `**kwargs` in `{fn_name}`.
- `@rx.memo` does not support positional-only parameters in `{
- UntypedComputedVarError(var_name=fget.__name__)
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/ed236575b8392a0b.
Report an issue: GitHub.