sprig-config
raw JSON → 1.4.8 verified Sat May 09 auth: no python
A Python library for loading and deep-merging configuration from multiple formats (YAML, JSON, TOML, Python dicts) with Spring-like profiles and variable interpolation. Supports include directives and environment variable substitution. Latest version 1.4.8, requires Python ≥3.13.
pip install sprig-config Common errors
error ModuleNotFoundError: No module named 'sprig_config' ↓
cause Wrong import name. The package is 'sprig-config' but the module is 'sprig'.
fix
Use: import sprig
error ModuleNotFoundError: No module named 'sprig' ↓
cause Package not installed or Python environment issue.
fix
Run: pip install sprig-config
Warnings
breaking Breaking: In version 1.0.0, the `load()` method changed from requiring a profile argument to using environment variable 'SPRIG_PROFILE'. Older code passing explicit profile must be updated. ↓
fix Set SPRIG_PROFILE env var before calling load(), or use new method `load_with_profile()` if available.
gotcha Gotcha: The package is imported as 'sprig' (underscore), not 'sprig-config' (hyphen). Users often mistakenly do `import sprig_config` or `from sprig-config import ...`. ↓
fix Use `import sprig` or `from sprig import Config`.
deprecated Deprecated: The `Config.from_dict()` class method is deprecated since v1.2.0. Use `Config().load_dict()` instead. ↓
fix Replace `Config.from_dict(data)` with `Config().load_dict(data)`.
Imports
- Config wrong
from sprig_config import Configcorrectfrom sprig import Config - load_config wrong
from sprig_config import loadcorrectfrom sprig import load_config
Quickstart
import os
from sprig import Config
# Optional: set a profile via environment variable
os.environ.setdefault('SPRIG_PROFILE', 'dev')
cfg = Config()
# Load config from file with profile and variable interpolation
cfg.load('config.yml')
# Access values using dot notation or dict-like access
database_host = cfg.get('database.host', 'localhost')
print(database_host)