Primitive types

We have several utility types that we use for our containers, that can also help end users as well.

Immutable

This class is useful when you need to make some instances immutable (like our containers are).

API Reference

graph TD; Immutable
class Immutable[source]

Bases: object

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

See returns.primitives.container.BaseContainer for examples.

Curry mypy plugin