Latest Results
Support hybrid_property on ObjectVar for nested dataclasses (#6619)
* feat: support hybrid_property on object vars (dataclass/model)
`rx._x.hybrid_property` previously only resolved as a frontend var when
accessed directly on a `State` class. Accessing it through an object var
(e.g. `State.info.a_b` where `info` is a dataclass, pydantic model or
SQLAlchemy model) raised `VarAttributeError`.
`ObjectVar.__getattr__` now detects a `HybridProperty` defined on the
underlying type and evaluates its frontend logic with the object var
substituted as `self`, so it renders with the same Var-access semantics
as accessing the hybrid property directly on the state. This works
uniformly across bare classes, pydantic models, SQLAlchemy models and
dataclasses, since they are all treated as object vars.
`HybridProperty` moved to `reflex_base.vars.hybrid_property` (so the var
system can reference it without an inverted dependency) and is still
re-exported from `reflex.experimental.hybrid_property`.
Fixes #6617
https://claude.ai/code/session_01DKFiYGnWRQG8wMNKFW7obm
* refactor: drop reflex.experimental.hybrid_property shim module
Import `hybrid_property` directly from `reflex_base.vars.hybrid_property`
in `reflex.experimental.__init__` instead of going through a one-line
re-export module. `from reflex.experimental import hybrid_property` and
`rx._x.hybrid_property` are unchanged.
https://claude.ai/code/session_01DKFiYGnWRQG8wMNKFW7obm
* fix: return the descriptor for class-level hybrid property access on non-states
HybridProperty.__get__ produced a frontend var for any class-level access,
which only makes sense on a state (whose class attributes are vars). On a
plain class accessed directly — e.g. `Info.a_b` on a dataclass, not through
an object var — it ran the getter with the class as `self`, raising
AttributeError (no field default) or returning a value built from class
defaults. It now returns the descriptor itself, like a normal property.
Var access through an object var (`State.info.a_b`) is unaffected: it is
resolved by ObjectVar.__getattr__ via _get_var, not __get__.
https://claude.ai/code/session_01DKFiYGnWRQG8wMNKFW7obm
* perf: detect hybrid properties via getattr instead of getattr_static
ObjectVar.__getattr__ ran inspect.getattr_static on every attribute access to
detect a HybridProperty on the underlying type — a pure-Python MRO walk on a hot
path, ~15x slower than getattr for ordinary field access. Now that
HybridProperty.__get__ returns the descriptor itself for non-state class access,
a plain getattr surfaces it directly, so the static lookup is no longer needed.
https://claude.ai/code/session_01DKFiYGnWRQG8wMNKFW7obm
* refactor: share one descriptor lookup for object var attribute access
Extract the class-attribute resolution into get_attribute_descriptor so
ObjectVar attribute access resolves the descriptor once and reuses it for
both HybridProperty detection and get_attribute_access_type, instead of
looking it up twice. Also hoist the HybridProperty import to module level
and flatten the branching in __getattr__.
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Farhan Ali Raza <farhanalirazaazeemi@gmail.com>
Co-authored-by: Farhan Ali Raza <62690310+FarhanAliRaza@users.noreply.github.com> updatecarlos/self-serve-integrations-docs-images updatecarlos/self-serve-integrations-docs-images Latest Branches
0%
0%
claude/hybrid-property-backend-var-guard 0%
carlos/self-serve-integrations-docs-images © 2026 CodSpeed Technology