eyconf.config.base.Config¶
- class eyconf.config.base.Config(data: dict | D, schema: type[D] | None = None, validator: Validator[D] | None = None)¶
Base configuration class.
This class allows to create configuration objects based on dataclass schemas. It provides methods for validation, updating, overwriting, and converting configuration data.
This can be used to create custom configuration classes in memory without file I/O.
Attributes
Get the configuration data.
Methods
__init__(data[, schema, validator])overwrite(data)Overwrite the configuration with provided data.
reset()Reset the configuration data to the default values.
to_dict()Convert the configuration data to a dictionary.
to_yaml()Convert the configuration data to a yaml string.
update(data)Update the configuration with provided data.
validate()Validate the current data against the schema.
- property data: D¶
Get the configuration data.
- overwrite(data: dict | D)¶
Overwrite the configuration with provided data.
If the provided data is missing required fields, an error will be raised.
- reset()¶
Reset the configuration data to the default values.
- update(data: dict[str, Any])¶
Update the configuration with provided data.
This applies an partial update to the existing configuration data. Only the provided keys will be updated, others will remain unchanged.
- validate()¶
Validate the current data against the schema.