class documentation

class MutableList(Mutable, List[_T]): (source)

View In Hierarchy

A list type that implements :class:`.Mutable`. The :class:`.MutableList` object implements a list that will emit change events to the underlying mapping when the contents of the list are altered, including when values are added or removed. Note that :class:`.MutableList` does **not** apply mutable tracking to the *values themselves* inside the list. Therefore it is not a sufficient solution for the use case of tracking deep changes to a *recursive* mutable structure, such as a JSON structure. To support this use case, build a subclass of :class:`.MutableList` 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. .. versionadded:: 1.1 .. seealso:: :class:`.MutableDict` :class:`.MutableSet`

Class Method coerce Convert plain list to instance of this class.
Method __delitem__ Detect list del events and emit change events.
Method __iadd__ Undocumented
Method __reduce_ex__ Undocumented
Method __setitem__ Detect list set events and emit change events.
Method __setstate__ Undocumented
Method append Undocumented
Method clear Undocumented
Method extend Undocumented
Method insert Undocumented
Method is_iterable Undocumented
Method is_scalar Undocumented
Method pop Undocumented
Method remove Undocumented
Method reverse Undocumented
Method sort 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: MutableList[_T]|_T) -> Optional[MutableList[_T]]: (source)

Convert plain list to instance of this class.

def __delitem__(self, index: SupportsIndex|slice): (source)

Detect list del events and emit change events.

def __iadd__(self, x: Iterable[_T]) -> MutableList[_T]: (source)

Undocumented

def __reduce_ex__(self, proto: SupportsIndex) -> Tuple[type, Tuple[List[int]]]: (source)

Undocumented

def __setitem__(self, index: SupportsIndex|slice, value: _T|Iterable[_T]): (source)

Detect list set events and emit change events.

def __setstate__(self, state: Iterable[_T]): (source)

Undocumented

def append(self, x: _T): (source)

Undocumented

def clear(self): (source)

Undocumented

def extend(self, x: Iterable[_T]): (source)

Undocumented

def insert(self, i: SupportsIndex, x: _T): (source)

Undocumented

def is_iterable(self, value: _T|Iterable[_T]) -> TypeGuard[Iterable[_T]]: (source)

Undocumented

def is_scalar(self, value: _T|Iterable[_T]) -> TypeGuard[_T]: (source)

Undocumented

def pop(self, *arg: SupportsIndex) -> _T: (source)

Undocumented

def remove(self, i: _T): (source)

Undocumented

def reverse(self): (source)

Undocumented

def sort(self, **kw: Any): (source)

Undocumented