forge.config¶
Typed, validated, layered configuration from environment variables, .env files,
and TOML configuration files.
forge.config ¶
Config module — layered configuration with pydantic-settings and TOML support.
Provides the ForgeConfig model with automatic environment-variable binding via pydantic-settings, the ConfigModule lifecycle wrapper, and utilities for loading TOML files, dotenv files, and deep merging.
Functions:¶
deep_merge ¶
field_is_sensitive ¶
Return True if name suggests it holds a secret value.
Source code in src/forge/config/secrets.py
is_secret ¶
Return True if value is or contains a secret.
Checks for SecretStr, SecretBytes, or any field name
containing api_key, password, secret, token.
Source code in src/forge/config/secrets.py
load_dotenv ¶
Load a .env file and return key-value pairs.
Supports:
- KEY=value
- KEY="quoted value"
- KEY='single quoted value'
- # comments
- Values containing = signs (e.g. connection strings)
Source code in src/forge/config/loaders.py
load_toml ¶
Parse a TOML file and return its contents as a dict.
Raises¶
ConfigurationError If the file cannot be parsed or contains circular references.
Source code in src/forge/config/loaders.py
mask_value ¶
Return a masked representation of value suitable for logging.
Actual secret values are never exposed in log output.
Source code in src/forge/config/secrets.py
merge_config ¶
Deep-merge overlay into base, returning a new dict.
Later values win. Nested dicts are merged recursively; all other values are replaced.
Source code in src/forge/config/loaders.py
str_from_secret ¶
Extract the plain-text string from a SecretStr, or return None.