akkudoktoreos.core.coreabc.get_config

akkudoktoreos.core.coreabc.get_config(init: bool | dict[str, bool] = False) ConfigEOS

Retrieve the singleton EOS configuration instance.

This function provides controlled access to the global EOS configuration singleton (ConfigEOS). The configuration is created lazily on first access and can be initialized with a configurable set of settings sources.

By default, accessing the configuration without prior initialization raises a RuntimeError. Passing init=True or an initialization configuration dictionary enables creation of the singleton.

Parameters:

init (Union[bool, dict[str, bool]]) –

Controls initialization of the configuration.

  • False (default): Do not initialize. Raises RuntimeError if the configuration does not yet exist.

  • True: Initialize the configuration using default initialization behavior (all settings sources enabled).

  • dict[str, bool]: Initialize the configuration with fine-grained control over which settings sources are enabled. Missing keys default to True.

Supported keys include:
  • with_init_settings

  • with_env_settings

  • with_dotenv_settings

  • with_file_settings

  • with_file_secret_settings

Returns:

The global EOS configuration singleton instance.

Return type:

ConfigEOS

Raises:

RuntimeError – If the configuration has not been initialized and init is False.

Usage:
# Initialize with default behavior (all sources enabled)
config = get_config(init=True)

# Initialize with explicit source control
config = get_config(init={
    "with_init_settings": True,
    "with_env_settings": True,
    "with_dotenv_settings": True,
    "with_file_settings": False,
    "with_file_secret_settings": False,
})

# Access existing configuration
host = get_config().server.host