fastoad.model_base.datacls module

Dataclass utilities.

fastoad.model_base.datacls.MANDATORY_FIELD = <object object>

To be put as default value for dataclass fields that should not have a default value. See BaseDataClass for further information.

class fastoad.model_base.datacls.BaseDataClass[source]

Bases: object

This class is a workaround for the following dataclass problem:

If a dataclass defines a field with a default value, inheritor classes will not be allowed to define fields without default value, because then the non-default fields will follow a default field, which is forbidden.

The chosen solution (from is to always define default values, but mandatory fields will have the MANDATORY_FIELD object as default.

After initialization, __post_init__() will process fields and raise an error if a field has MANDATORY_FIELD as value.