state: unbreak backend vars
This one was really esoteric... if backend vars are used, then a `model_post_init` gets synthesized, and reflex tries to treat that as an event handler... but the args cannot convert correctly, so it raises a validation error when attempting to instantiate the EventSpec (which is also a BaseModel).
This commit is contained in:
parent
325c638379
commit
62d36bfecc
@ -153,6 +153,10 @@ RESERVED_BACKEND_VAR_NAMES = {
|
|||||||
"_abc_impl", # pydantic v2 adds this
|
"_abc_impl", # pydantic v2 adds this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPECIAL_METHODS = {
|
||||||
|
"model_post_init", # never treat this as an event handler
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
||||||
"""The state of the app."""
|
"""The state of the app."""
|
||||||
@ -358,6 +362,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|||||||
name: fn
|
name: fn
|
||||||
for name, fn in cls.__dict__.items()
|
for name, fn in cls.__dict__.items()
|
||||||
if not name.startswith("_")
|
if not name.startswith("_")
|
||||||
|
and name not in SPECIAL_METHODS
|
||||||
and isinstance(fn, Callable)
|
and isinstance(fn, Callable)
|
||||||
and not isinstance(fn, EventHandler)
|
and not isinstance(fn, EventHandler)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user