We have several utility types that we use for our containers, that can also help end users as well.
This class is useful when you need to make some instances immutable (like our containers are).
Helper type for objects that should be immutable.
When applied, each instance becomes immutable. Nothing can be added or deleted from it.
>>> from returns.primitives.types import Immutable >>> class MyModel(Immutable): ... ... >>> model = MyModel() >>> model.prop = 1 Traceback (most recent call last): ... returns.primitives.exceptions.ImmutableStateError
returns.primitives.container.BaseContainer for examples.
Raised when a container can not be unwrapped into a meaningful value.
container (Unwrappable) –
Raised when a container is forced to be mutated.
It is a sublclass of
AttributeError for two reasons:
It seems kinda reasonable to expect
on attribute modification
It is used inside
typing.py this way,
we do have several typing features that requires that behaviour