Ligare.programming.config

Ligare.programming’s API for working with configuration files.

Functions

load_config(config_type, toml_file_path[, ...])

Load configuration data from a TOML file into a TConfig object instance

Classes

AbstractConfig()

The base type for all pluggable config types.

Config(**data)

ConfigBuilder()

class Ligare.programming.config.AbstractConfig[source]

The base type for all pluggable config types.

abstract post_load()[source]

This method is called by load_config after TOML data has been loaded into the pluggable config type instance.

Return type:

None

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].

post_load()[source]

This method is called by load_config after TOML data has been loaded into the pluggable config type instance.

Return type:

None

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:
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

with_root_config(config_type)[source]

Set config_type as the “root” config, used during build.

Parameters:

config_type (type[TConfig])

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

Exceptions raised by the configuration system.