eyconf.config.extra_fields.ConfigExtra

class eyconf.config.extra_fields.ConfigExtra(data: dict | D, schema: type[D] | None = None)

Configuration class that supports extra fields explicitly.

This class extends the base configuration functionality to allow for additional fields that are not defined in the original schema.

This additional fields are accessible via the extra_data property. They are merged into the schema data when accessing via the data property.

Attributes

data

Get the configuration data wrapped in a dynamic accessor.

extra_data

Get the extra data as an AttributeDict.

schema_data

Get the schema dataclass type excluding extra fields.

Methods

__init__(data[, schema])

overwrite(data)

Overwrite the configuration with provided data.

reset()

Reset the configuration data to the default values.

to_dict([extra_fields])

Get the full configuration data as a dictionary, including extra fields.

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.

__init__(data: dict | D, schema: type[D] | None = None)
property data: AccessProxy[D]

Get the configuration data wrapped in a dynamic accessor.

Care: Instance checks will not work as expected on this property.

property extra_data: AttributeDict

Get the extra data as an AttributeDict.

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.

property schema_data: D

Get the schema dataclass type excluding extra fields.

to_dict(extra_fields: bool = True) dict

Get the full configuration data as a dictionary, including extra fields.

to_yaml() str

Convert the configuration data to a yaml string.

update(data: dict)

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.