ListConfigSource#
- pydantic model tollan.config.sources.ListConfigSource[source]#
Configuration source from nested list of sources.
This allows hierarchical composition of config sources. The source can be a ConfigSourceList, or a list/dict that will be validated into a ConfigSourceList.
Examples
>>> from . import ConfigSourceList >>> from .dict_ import DictConfigSource >>> sources = ConfigSourceList(data=[ ... DictConfigSource(order=0, source={"base": True}), ... DictConfigSource(order=1, source={"override": True}) ... ]) >>> src = ListConfigSource(order=0, source=sources) >>> src.format 'list' >>> src.load() {'base': True, 'override': True}
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.Show JSON schema
{ "title": "ListConfigSource", "description": "Configuration source from nested list of sources.\n\nThis allows hierarchical composition of config sources.\nThe source can be a ConfigSourceList, or a list/dict that will\nbe validated into a ConfigSourceList.\n\nExamples\n--------\n>>> from . import ConfigSourceList\n>>> from .dict_ import DictConfigSource\n>>> sources = ConfigSourceList(data=[\n... DictConfigSource(order=0, source={\"base\": True}),\n... DictConfigSource(order=1, source={\"override\": True})\n... ])\n>>> src = ListConfigSource(order=0, source=sources)\n>>> src.format\n'list'\n>>> src.load()\n{'base': True, 'override': True}", "type": "object", "properties": { "order": { "title": "Order", "type": "integer" }, "name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Name" }, "enabled": { "default": true, "title": "Enabled", "type": "boolean" }, "enable_if": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Enable If" }, "format": { "const": "list", "default": "list", "title": "Format", "type": "string" }, "source": { "type": "object" } }, "required": [ "order", "source" ] }
- Config:
frozen: bool = True
- Fields:
- Validators:
_validate_name»all fields_validate_source»source
- field format: Literal['list'] = 'list'#
Format identifier, always ‘list’
- Validated by:
_validate_name
- field source: Annotated['ConfigSourceList', WithJsonSchema({'type': 'object'})] [Required]#
Nested list of configuration sources
- Constraints:
json_schema = {‘type’: ‘object’}
- Validated by:
_validate_name_validate_source
- load(context: dict[str, Any] | None = None) DictConfigT[source]#
Load configuration from nested source list.
- Parameters:
context (dict[str, Any] | None, optional) – Context dictionary (passed to nested sources)
- Returns:
Merged configuration dictionary
- Return type:
DictConfigT
- Raises:
ValueError – If source is not enabled for context