corset.serialize#

class corset.serialize.YamlSerializableMixin#

Mixin class to add YAML serialization/deserialization to dataclasses and a few other common types.

classmethod load_yaml(filename) Self#

Load an object from a YAML file.

If this is called from a subclass the loaded object type must match that subclass.

Parameters:

filename (str | Path) – Path to the YAML file.

Return type:

Self

Returns:

The loaded object.

Raises:
  • ValueError – If the YAML file does not contain a ‘data’ field.

  • TypeError – If the loaded object type does not match the class used to call this method.

save_yaml(filename) None#

Save the object to a YAML file.

Parameters:
  • filename (str | Path) – Path to the YAML file.

  • self (Any)

Return type:

None

corset.serialize.load_yaml(filename) Self#

Load any YamlSerializableMixin instance or basic collection containing them from a YAML file. This is an alias for YamlSerializableMixin.load_yaml().

Return type:

Self

Parameters:

filename (str | Path)

corset.serialize.save_yaml(self, filename) None#

Save any YamlSerializableMixin instance or basic collection containing them to a YAML file. This is an alias for YamlSerializableMixin.save_yaml().

Return type:

None

Parameters: