Ligare.programming.config
Ligare.programming’s API for working with configuration files.
Functions
|
Load configuration data from a TOML file into a TConfig object instance |
Classes
The base type for all pluggable config types. |
|
|
|
- class Ligare.programming.config.AbstractConfig[source]
The base type for all pluggable config types.
- class Ligare.programming.config.Config(**data)[source]
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class Ligare.programming.config.ConfigBuilder[source]
- build()[source]
Create a TConfig type from the provided build options.
At least one “root” config, or one pluggable config must be added. If a “root” config is not added, the first pluggable config added is used as the root config.
- Raises:
ConfigBuilderStateError – Raised when the Builder is misconfigured
NotEndsWithConfigError – Raised when a pluggable config type’s name does not end with Config
- Return type[TConfig]:
The TConfig type, including any pluggable config types
- Return type:
type
[TypeVar
(TConfig
, bound=AbstractConfig
)]
- with_config(config_type)[source]
Add a pluggable config type that is added to the root TConfig type during build.
- Parameters:
config_type (type[AbstractConfig])
- Return Self:
- Return type:
Self
- with_configs(configs)[source]
Add a list of pluggable config types that are added to the root TConfig type during build.
- Parameters:
configs (list[type[AbstractConfig]] | None)
- Return Self:
- Return type:
Self
- Ligare.programming.config.load_config(config_type, toml_file_path, config_overrides=None)[source]
Load configuration data from a TOML file into a TConfig object instance
config_type.post_load is called on the root config type _only_.
- Parameters:
config_type (type[TConfig]) – The configuration type that is instantiated and hydrated with data from the TOML file.
toml_file_path (str | Path) – The path to the TOML file to load.
config_overrides (AnyDict | None) – Explicit data used to override any data in the TOML file, defaults to None
- Return TConfig:
The hydrated configuration object
- Return type:
TypeVar
(TConfig
, bound=AbstractConfig
)
Modules
Exceptions raised by the configuration system. |