Skip to content

BaseConfig

BaseConfig

Bases: BaseSettings

Base configuration class that extends Pydantic's BaseSettings. Provides utility methods to load configurations from various sources.

ensure_config(config) classmethod

Ensure the config is an instance of the current config class.

If the input is a dictionary, string, or path to a YAML/JSON file, it is loaded and converted into an instance of the class.

Parameters:

  • config (T | Path | str | Dict) –

    The input configuration, which can be an instance of the config class, a dictionary, a file path, or a string.

Returns:

  • T

    An instance of the current configuration class.

Raises:

  • FileNotFoundError

    If the provided file path does not exist.

  • ValueError

    If the file type is unsupported.

  • TypeError

    If the input type is not supported.