ENG-9859 fix(state): preserve source function __dict__ and kwdefaults in _copy…#6725
Conversation
…_fn (ENG-9859) When the State metaclass pulls a computed-var getter or event handler in from a mixin, _copy_fn rebuilds the function via FunctionType, which drops the function's __dict__. Previously it hand-copied only the background-task and event-actions markers back on, silently losing any other attribute a framework or downstream user set on the getter/handler. Copy the full __dict__ onto the copy, which subsumes the per-marker copies and lets arbitrary markers (e.g. Reflex Enterprise's _auth tag) survive mixin inheritance. Also carry __kwdefaults__, which FunctionType likewise drops — without it a mixin handler with a keyword-only default raised TypeError when called through the subclass.
Greptile SummaryThis PR fixes
Confidence Score: 5/5Safe to merge — the change is a narrow, well-tested fix to function copying in mixin inheritance with no impact on the broader state machinery. The fix replaces explicit per-attribute copies with a clean No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "chore: shorten changelog entry" | Re-trigger Greptile |
Merging this PR will not alter performance
Comparing Footnotes
|
masenf
left a comment
There was a problem hiding this comment.
looks good, needs a changelog entry
…_fn (ENG-9859)
When the State metaclass pulls a computed-var getter or event handler in from a mixin, _copy_fn rebuilds the function via FunctionType, which drops the function's dict. Previously it hand-copied only the background-task and event-actions markers back on, silently losing any other attribute a framework or downstream user set on the getter/handler.
Copy the full dict onto the copy, which subsumes the per-marker copies and lets arbitrary markers (e.g. Reflex Enterprise's _auth tag) survive mixin inheritance. Also carry kwdefaults, which FunctionType likewise drops — without it a mixin handler with a keyword-only default raised TypeError when called through the subclass.
All Submissions:
Type of change
Please delete options that are not relevant.
New Feature Submission:
Changes To Core Features: