devctrl.utility.settings.SettingsClass#

class SettingsClass[source]#

Bases: object

Base class for settings classes. Use the @dataclass decorator on sub-classes as well. Data class with extra features: - __or__ operator - instantiate from dictionary - load/save from/to yaml

Methods

as_dict

Convenience wrapper for dataclasses.asdict(self)

from_dict

Recursively construct a SettingsClass from a dictionary.

load_yaml

save_yaml

as_dict() dict[source]#

Convenience wrapper for dataclasses.asdict(self)

classmethod from_dict(data: dict)[source]#

Recursively construct a SettingsClass from a dictionary. If the value of a field is another SettingsClass, from_dict will be called for that field as well. Handled are: - SettingsClass - list[SettingsClass] - dict[<any>, SettingsClass] - all of the above as Optional

Raises:
  • ValueError – If data contains a value that has the wrong type for the field of cls (ONLY if the type is a subclass of SettingsClass! Other types are not enforced)

  • KeyError – If data contains a key that is not a field name of cls