typed_mapping

FOX.typed_mapping

A module which adds the TypedMapping class.

Index

TypedMapping() A Mapping type which only allows a specific set of keys.
TypedMapping.__setattr__(name, value) Implement setattr(self, name, value).
TypedMapping.__delattr__(name) Implement delattr(self, name).
TypedMapping.__setitem__(name, value) Implement self[name] = value.
TypedMapping.__bool__ Get the __bool__() method of TypedMapping.view.
TypedMapping.__getitem__ Get the __getitem__() method of TypedMapping.view.
TypedMapping.__iter__ Get the __iter__() method of TypedMapping.view.
TypedMapping.__len__ Get the __len__() method of TypedMapping.view.
TypedMapping.__contains__ Get the __contains__() method of TypedMapping.view.
TypedMapping.get Get the get() method of TypedMapping.view.
TypedMapping.keys Get the keys() method of TypedMapping.view.
TypedMapping.items Get the items() method of TypedMapping.view.
TypedMapping.values Get the values() method of TypedMapping.view.

API

class FOX.typed_mapping.TypedMapping[source]

A Mapping type which only allows a specific set of keys.

Values cannot be altered after their assignment.

_PRIVATE_ATTR

A frozenset defining all private instance variables.

Type:frozenset [str], classvar
_ATTR

A frozenset containing all allowed keys. Should be defined at the class level.

Type:frozenset [str], classvar
view

Return a read-only view of all items specified in TypedMapping._ATTR.

Type:MappingProxyType [str, Any]
TypedMapping.__setattr__(name, value)[source]

Implement setattr(self, name, value).

Attributes specified in TypedMapping._PRIVATE_ATTR can freely modified. Attributes specified in TypedMapping._ATTR can only be modified when the previous value is None. All other attribute cannot be modified any further.

Return type:None
TypedMapping.__delattr__(name)[source]

Implement delattr(self, name).

Raises an AttributeError, instance variables cannot be deleted.

Return type:NoReturn
TypedMapping.__setitem__(name, value)[source]

Implement self[name] = value.

Serves as an alias for TypedMapping.__setattr__() when name is in TypedMapping._ATTR().

Return type:None
TypedMapping.__bool__()

Get the __bool__() method of TypedMapping.view.

Return type:Callable[[], bool]
TypedMapping.__getitem__()

Get the __getitem__() method of TypedMapping.view.

Return type:Callable[[~KT], ~KV]
TypedMapping.__iter__()

Get the __iter__() method of TypedMapping.view.

Return type:Callable[[], Iterator[~KT]]
TypedMapping.__len__()

Get the __len__() method of TypedMapping.view.

Return type:Callable[[], int]
TypedMapping.__contains__()

Get the __contains__() method of TypedMapping.view.

Return type:Callable[[~KT], bool]
TypedMapping.get()

Get the get() method of TypedMapping.view.

Return type:Callable[[~KT, Optional[Any]], ~KV]
TypedMapping.keys()

Get the keys() method of TypedMapping.view.

Return type:Callable[[], KeysView[~KT]]
TypedMapping.items()

Get the items() method of TypedMapping.view.

Return type:Callable[[], ItemsView[~KT, ~KV]]
TypedMapping.values()

Get the values() method of TypedMapping.view.

Return type:Callable[[], ValuesView[~KV]]