class documentation

class MutableDict(Mutable, Dict[_KT, _VT]): (source)

View In Hierarchy

A dictionary type that implements :class:`.Mutable`. The :class:`.MutableDict` object implements a dictionary that will emit change events to the underlying mapping when the contents of the dictionary are altered, including when values are added or removed. Note that :class:`.MutableDict` does **not** apply mutable tracking to the *values themselves* inside the dictionary. Therefore it is not a sufficient solution for the use case of tracking deep changes to a *recursive* dictionary structure, such as a JSON structure. To support this use case, build a subclass of :class:`.MutableDict` that provides appropriate coercion to the values placed in the dictionary so that they too are "mutable", and emit events up to their parent structure. .. seealso:: :class:`.MutableList` :class:`.MutableSet`

Class Method coerce Convert plain dictionary to instance of this class.
Method __delitem__ Detect dictionary del events and emit change events.
Method __getstate__ Undocumented
Method __setitem__ Detect dictionary set events and emit change events.
Method __setstate__ Undocumented
Method clear Undocumented
Method pop Undocumented
Method popitem Undocumented
Method setdefault Undocumented
Method update Undocumented

Inherited from Mutable:

Class Method as_mutable Associate a SQL type with this mutable Python type.
Class Method associate_with Associate this wrapper with all future mapped columns of the given type.
Class Method associate_with_attribute Establish this type as a mutation listener for the given mapped descriptor.
Method changed Subclasses should call this method whenever change events occur.

Inherited from MutableBase (via Mutable):

Class Method _get_listen_keys Given a descriptor attribute, return a ``set()`` of the attribute keys which indicate a change in the state of this attribute.
Class Method _listen_on_attribute Establish this type as a mutation listener for the given mapped descriptor.
Property _parents Dictionary of parent object's :class:`.InstanceState`->attribute name on the parent.
@classmethod
def coerce(cls, key: str, value: Any) -> MutableDict[_KT, _VT]|None: (source)

Convert plain dictionary to instance of this class.

def __delitem__(self, key: _KT): (source)

Detect dictionary del events and emit change events.

def __getstate__(self) -> Dict[_KT, _VT]: (source)

Undocumented

def __setitem__(self, key: _KT, value: _VT): (source)

Detect dictionary set events and emit change events.

def __setstate__(self, state: Union[Dict[str, int], Dict[str, str]]): (source)

Undocumented

def clear(self): (source)

Undocumented

@overload
def pop(self, __key: _KT) -> _VT:
@overload
def pop(self, __key: _KT, __default: _VT|_T) -> _VT|_T:
(source)

Undocumented

def popitem(self) -> Tuple[_KT, _VT]: (source)

Undocumented

@overload
def setdefault(self: MutableDict[_KT, Optional[_T]], key: _KT, value: None = None) -> Optional[_T]:
@overload
def setdefault(self, key: _KT, value: _VT) -> _VT:
(source)

Undocumented

def update(self, *a: Any, **kw: _VT): (source)

Undocumented