Skip to content

Follow-ups from #7215: dead statement in test_reserved_mixin_var, typed _reflex_state_root default, document the type(rx.State) is BaseStateMeta contract #7264

Description

@masenf

Three follow-ups recorded in the #7215 review (reserved-name validation moved into BaseStateMeta.__new__), all out of scope for that PR:

  1. tests/units/test_state.py::test_reserved_mixin_var[state_mixin=True] has a dead statement. For that parametrization the reserved name is rejected at the mixin's own declaration, so the second type("MixedState", …) statement never runs. Pre-existing since Validate reserved state names before registration #7136 (the test was moved verbatim). Restructure it so each parametrization asserts where the rejection happens.
  2. Replace the getattr(base, "_reflex_state_root", None) lookup over the bases in BaseStateMeta.__new__ (packages/reflex-base/src/reflex_base/vars/base.py) with a typed metaclass default (_reflex_state_root: BaseStateMeta | None = None) and limit the lookup to the EvenMoreBasicBaseState bases. Removes the string literal and the getattr.
  3. Document the contract in the BaseStateMeta docstring: type(rx.State) is BaseStateMeta is supported (downstream metaclasses derive from it; reflex-enterprise's OIDCCookieMeta does), state_root= and mixin= are class keywords the metaclass understands, and _reflex_state_root is a reserved name. Its absence is what let 0.9.12a1 ship the sibling metaclass that caused 0.9.12a1: metaclass conflict for State subclasses using a BaseStateMeta-derived metaclass (breaks reflex-enterprise 0.9.5 auth/MCP/REST apps at startup) #7211.

Source: fixes/f001/REPORT.md, "PR review follow-ups", and the #7215 description.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions