dang it darglint
This commit is contained in:
parent
5cd04b4176
commit
ed9c351141
@ -104,6 +104,7 @@ from reflex.utils.exceptions import (
|
|||||||
LockExpiredError,
|
LockExpiredError,
|
||||||
ReflexRuntimeError,
|
ReflexRuntimeError,
|
||||||
SetUndefinedStateVarError,
|
SetUndefinedStateVarError,
|
||||||
|
StateMismatchError,
|
||||||
StateSchemaMismatchError,
|
StateSchemaMismatchError,
|
||||||
StateSerializationError,
|
StateSerializationError,
|
||||||
StateTooLargeError,
|
StateTooLargeError,
|
||||||
@ -1551,11 +1552,14 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
The instance of state_cls associated with this state's client_token.
|
The instance of state_cls associated with this state's client_token.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
StateMismatchError: If the state instance is not of the expected type.
|
||||||
"""
|
"""
|
||||||
root_state = self._get_root_state()
|
root_state = self._get_root_state()
|
||||||
substate = root_state.get_substate(state_cls.get_full_name().split("."))
|
substate = root_state.get_substate(state_cls.get_full_name().split("."))
|
||||||
if not isinstance(substate, state_cls):
|
if not isinstance(substate, state_cls):
|
||||||
raise ValueError(
|
raise StateMismatchError(
|
||||||
f"Searched for state {state_cls.get_full_name()} but found {substate}."
|
f"Searched for state {state_cls.get_full_name()} but found {substate}."
|
||||||
)
|
)
|
||||||
return substate
|
return substate
|
||||||
@ -1571,6 +1575,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
RuntimeError: If redis is not used in this backend process.
|
RuntimeError: If redis is not used in this backend process.
|
||||||
|
StateMismatchError: If the state instance is not of the expected type.
|
||||||
"""
|
"""
|
||||||
# Fetch all missing parent states from redis.
|
# Fetch all missing parent states from redis.
|
||||||
parent_state_of_state_cls = await self._populate_parent_states(state_cls)
|
parent_state_of_state_cls = await self._populate_parent_states(state_cls)
|
||||||
@ -1591,7 +1596,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if not isinstance(state_in_redis, state_cls):
|
if not isinstance(state_in_redis, state_cls):
|
||||||
raise ValueError(
|
raise StateMismatchError(
|
||||||
f"Searched for state {state_cls.get_full_name()} but found {state_in_redis}."
|
f"Searched for state {state_cls.get_full_name()} but found {state_in_redis}."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -163,6 +163,10 @@ class StateSerializationError(ReflexError):
|
|||||||
"""Raised when the state cannot be serialized."""
|
"""Raised when the state cannot be serialized."""
|
||||||
|
|
||||||
|
|
||||||
|
class StateMismatchError(ReflexError, ValueError):
|
||||||
|
"""Raised when the state retrieved does not match the expected state."""
|
||||||
|
|
||||||
|
|
||||||
class SystemPackageMissingError(ReflexError):
|
class SystemPackageMissingError(ReflexError):
|
||||||
"""Raised when a system package is missing."""
|
"""Raised when a system package is missing."""
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user