Use ._is_mutable()
to account for parent state proxy (#3739)
When a parent state proxy is set, also allow child StateProxy._self_mutable to override the parent's `_is_mutable()`.
This commit is contained in:
parent
7d9ed7e2ce
commit
3309c0e533
@ -2059,7 +2059,7 @@ class StateProxy(wrapt.ObjectProxy):
|
|||||||
Whether the state is mutable.
|
Whether the state is mutable.
|
||||||
"""
|
"""
|
||||||
if self._self_parent_state_proxy is not None:
|
if self._self_parent_state_proxy is not None:
|
||||||
return self._self_parent_state_proxy._is_mutable()
|
return self._self_parent_state_proxy._is_mutable() or self._self_mutable
|
||||||
return self._self_mutable
|
return self._self_mutable
|
||||||
|
|
||||||
async def __aenter__(self) -> StateProxy:
|
async def __aenter__(self) -> StateProxy:
|
||||||
@ -3302,7 +3302,7 @@ class ImmutableMutableProxy(MutableProxy):
|
|||||||
Raises:
|
Raises:
|
||||||
ImmutableStateError: if the StateProxy is not mutable.
|
ImmutableStateError: if the StateProxy is not mutable.
|
||||||
"""
|
"""
|
||||||
if not self._self_state._self_mutable:
|
if not self._self_state._is_mutable():
|
||||||
raise ImmutableStateError(
|
raise ImmutableStateError(
|
||||||
"Background task StateProxy is immutable outside of a context "
|
"Background task StateProxy is immutable outside of a context "
|
||||||
"manager. Use `async with self` to modify state."
|
"manager. Use `async with self` to modify state."
|
||||||
|
Loading…
Reference in New Issue
Block a user