backend vars logic is now supported
This commit is contained in:
parent
bb8d7c5d15
commit
c51d6752c6
@ -1282,9 +1282,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
||||
return
|
||||
|
||||
if (
|
||||
not name.startswith(
|
||||
"_"
|
||||
) # TODO: skipping backend vars and vars with double leading underscores for now. They should be supported, however.
|
||||
not name.startswith("__")
|
||||
and not name.startswith(f"_{type(self).__name__}__")
|
||||
and name not in self.vars
|
||||
and name not in self.get_skip_vars()
|
||||
):
|
||||
|
@ -41,6 +41,7 @@ from reflex.state import (
|
||||
)
|
||||
from reflex.testing import chdir
|
||||
from reflex.utils import format, prerequisites, types
|
||||
from reflex.utils.exceptions import SetUndefinedStateVarError
|
||||
from reflex.utils.format import json_dumps
|
||||
from reflex.vars.base import ComputedVar, Var
|
||||
from tests.units.states.mutation import MutableSQLAModel, MutableTestState
|
||||
@ -3293,17 +3294,14 @@ def test_assignment_to_undeclared_vars():
|
||||
state = State() # type: ignore
|
||||
sub_state = Substate() # type: ignore
|
||||
|
||||
with pytest.raises(AttributeError):
|
||||
with pytest.raises(SetUndefinedStateVarError):
|
||||
state.handle_regular_var()
|
||||
|
||||
with pytest.raises(AttributeError):
|
||||
with pytest.raises(SetUndefinedStateVarError):
|
||||
sub_state.handle_var()
|
||||
|
||||
# TODO: uncomment this if the case of backend vars are supported.
|
||||
# with pytest.raises(AttributeError):
|
||||
# state.handle_backend_var()
|
||||
#
|
||||
# with pytest.raises(AttributeError):
|
||||
# state.handle_non_var()
|
||||
with pytest.raises(SetUndefinedStateVarError):
|
||||
state.handle_backend_var()
|
||||
|
||||
state.handle_supported_regular_vars()
|
||||
state.handle_non_var()
|
||||
|
Loading…
Reference in New Issue
Block a user