stp.utils.typed_key_dict

This module contains data structures to define TypedKeyDict.

Module Contents

Classes

TypedKey

A key that contains type information about the value.

TypedKeyDict

A dictionary with type information where the key encodes information about the

Attributes

ValueInterfaceT

ValueConcreteT

stp.utils.typed_key_dict.ValueInterfaceT
stp.utils.typed_key_dict.ValueConcreteT
class stp.utils.typed_key_dict.TypedKey(cls: Type[ValueConcreteT])

Bases: Generic[ValueConcreteT]

A key that contains type information about the value.

__slots__ = ['concrete_cls']
value_t() Type[ValueConcreteT]

Returns the type of the value for this key. :return: The type of the value for this key.

class stp.utils.typed_key_dict.TypedKeyDict

Bases: Generic[ValueInterfaceT], collections.abc.MutableMapping

A dictionary with type information where the key encodes information about the subclass so that the correct subclass can be retrieved without an additional instanceof check.

__slots__ = ['_dict']
__getitem__(key: TypedKey[ValueConcreteT]) ValueConcreteT
__setitem__(key: TypedKey[ValueConcreteT], value: ValueConcreteT) None
__delitem__(key: TypedKey[ValueConcreteT]) None
__len__() int
__iter__()
__contains__(item) bool