Commit 65a2889
authored
ENG-9860 fix(vars): preserve custom Field attributes in state metaclass (#6726)
* fix(vars): preserve custom Field attributes in state metaclass
BaseStateMeta rebuilt Field instances for state annotations, discarding
any custom attributes callers had set. Copy over attrs the rebuilt field
did not recompute via Field._copy_custom_attrs_from so subclassed or
customized fields keep their extra state.
* fix(vars): deep-copy custom Field attrs and skip reserved annotation
Fold custom-attribute copying into Field.__init__ via a source_field
parameter instead of the post-hoc _copy_custom_attrs_from helper.
Copied attrs are now deep-copied so mutable values aren't shared
between the original and rebuilt fields, and the reserved `annotation`
attribute is never carried over — get_field_type duck-types pydantic
fields on `.annotation`, so copying it would shadow the real class
annotation.1 parent 32f41e2 commit 65a2889
4 files changed
Lines changed: 96 additions & 0 deletions
File tree
- packages/reflex-base
- news
- src/reflex_base/vars
- tests/units/reflex_base/vars
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3470 | 3470 | | |
3471 | 3471 | | |
3472 | 3472 | | |
| 3473 | + | |
| 3474 | + | |
| 3475 | + | |
| 3476 | + | |
| 3477 | + | |
3473 | 3478 | | |
3474 | 3479 | | |
3475 | 3480 | | |
| |||
3486 | 3491 | | |
3487 | 3492 | | |
3488 | 3493 | | |
| 3494 | + | |
3489 | 3495 | | |
3490 | 3496 | | |
3491 | 3497 | | |
| |||
3494 | 3500 | | |
3495 | 3501 | | |
3496 | 3502 | | |
| 3503 | + | |
| 3504 | + | |
3497 | 3505 | | |
3498 | 3506 | | |
3499 | 3507 | | |
| |||
3524 | 3532 | | |
3525 | 3533 | | |
3526 | 3534 | | |
| 3535 | + | |
| 3536 | + | |
| 3537 | + | |
| 3538 | + | |
3527 | 3539 | | |
3528 | 3540 | | |
3529 | 3541 | | |
| |||
3770 | 3782 | | |
3771 | 3783 | | |
3772 | 3784 | | |
| 3785 | + | |
3773 | 3786 | | |
3774 | 3787 | | |
3775 | 3788 | | |
3776 | 3789 | | |
3777 | 3790 | | |
3778 | 3791 | | |
| 3792 | + | |
3779 | 3793 | | |
3780 | 3794 | | |
3781 | 3795 | | |
| |||
3825 | 3839 | | |
3826 | 3840 | | |
3827 | 3841 | | |
| 3842 | + | |
3828 | 3843 | | |
3829 | 3844 | | |
3830 | 3845 | | |
| |||
Whitespace-only changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
0 commit comments