fix(memo): preserve runtime typing for unannotated params#6659
fix(memo): preserve runtime typing for unannotated params#6659harsh21234i wants to merge 9 commits into
Conversation
Greptile SummaryThis PR restores the pre-0.9.4 behavior for
Confidence Score: 5/5Safe to merge — the change is scoped to unannotated @rx.memo params, lazy-body caching semantics ensure the runtime dict is only consulted on the first definition.component access, and cleanup is guarded by finally. The mechanism is sound: _runtime_param_values is held by reference in both the frozen dataclass and the closure, so mutations before the first lazy evaluation are visible to the thunk. The finally cleanup prevents stale values from leaking. Both inference branches now have test coverage, and the change does not affect annotated parameters. No files require special attention. Important Files Changed
Reviews (9): Last reviewed commit: "Merge branch 'reflex-dev:main' into fix/..." | Re-trigger Greptile |
Merging this PR will not alter performance
Comparing Footnotes
|
|
any update? @masenf |
…r-regression-6631 # Conflicts: # packages/reflex-base/src/reflex_base/components/memo.py
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
|
for the runtime type check, i meant, inside the memo function body, there should be an assertion that the overall i like the compatibility with the previous implementation, but it would be nice if this path raised some kind of deprecation warning indicating to users that they should be typing their memo function args for best results. |
Summary
Fixes #6631.
@rx.memocomponent bodies with unannotated parameters were regressing toVar[Any]in 0.9.4, which caused downstreamUntypedVarErrorfailures when the memo bodytried to access object fields or call var methods.
This change preserves the legacy behavior for missing annotations by seeding the memo body with the first call’s runtime value type before the component is
materialized. That keeps the deprecation warning in place, but avoids the confusing compile-time failure for existing call sites.
Testing
uv run pytest -o addopts='' tests/units/components/test_memo.py -q