yaloader.YAMLBaseConfig#

class yaloader.YAMLBaseConfig[source]#

Bases: BaseModel

The base class for all config objects which are loaded from or dumped to yaml files.

Each config from which an actual object can be created has to implement the YAMLBaseConfig.load() method.

classmethod get_yaml_tag() str[source]#

Return the configs yaml tag.

load(*args, **kwargs)[source]#

Create the object the yaml config object is for.

This basic constructor uses all attributes of the config as kwargs for the loaded class.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'validate_assignment': True}#

Since yaml configs are used to create instances extra fields are forbidden.

model_fields: ClassVar[dict[str, FieldInfo]] = {}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

model_post_init(__context: Any) None#

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • __context – The context.

classmethod set_yaml_tag(yaml_tag: str | None) None[source]#

Set the yaml tag of the config.

A valid tag has to start with an exclamation mark.

Parameters:

yaml_tag – Optional string of the tag. If None the tag will be set to a default value.

validate_config(force_all: bool = False) None[source]#

Validate a BaseConfig instance

If force_all is False do not raise an error on missing attributes. Configs have to be correct but may be incomplete.

Parameters:

force_all – If True raise an error on missing attributes