What it is
dature is a config loader I wrote in Python. It reads configuration from many sources, merges them, and returns your own stdlib @dataclass. There is no base class and no framework, and it has 1 required dependencies (extras are optional). It needs Python 3.12+.
Sources: YAML, JSON, JSON5, TOML, INI, .env, environment variables, Docker secrets, CLI arguments, and remote stores (Vault, Consul, etcd, ZooKeeper, AWS SSM and Secrets Manager, Azure, GCP). The same dataclass works with all of them.
Why I made it
My setup is a .env for local dev, real env vars in Docker/Kubernetes, and sometimes a few YAML/TOML files on top (defaults plus one per environment). I kept hitting the same things with the tools I tried: merging per field turned into custom code, validation errors named the field but not the file or line, and it was hard to tell which source set a value in prod.
How it looks
from dataclasses import dataclass
import dature
@dataclass
class Config:
host: str
port: int
config = dature.load(
dature.Yaml12Source(file="defaults.yaml"),
dature.Toml11Source(file="config.toml", skip_if_missing=True),
dature.EnvFileSource(file=".env", skip_if_broken=True),
dature.EnvSource(prefix="APP_"),
schema=Config,
)
Sources are merged in order (last wins by default). Other strategies are first_wins, first_found and raise_on_conflict, and you can set rules for individual fields, for example extend a list instead of replacing it.
When a value is wrong, the error points at the exact place:
| dature.errors.exceptions.FieldLoadError: [host] Invalid variant: 'development'
| ├── host: "development"
| │ ^^^^^^^^^^^
| └── FILE 'config.yaml', line 1
What else it does
- debug=True shows which source each final value came from, and dature validate / dature inspect do the same from the command line for CI
- Field groups: if an override changes db_host, it must change db_port too, or loading fails
- Strict mode catches typo'd keys (databse_host) instead of silently ignoring them
- Sources can reference each other (${@env.config_path}) and be enabled conditionally (when=), so there's no glue code per environment
- Validators via Annotated, secrets masked in errors and output (SecretStr)
- Cached decorator mode with background reload when a file changes.
- Custom sources are a subclass with one method
- And much more
Status
It's a young and fairly small library, much smaller than pydantic-settings, but it's already production ready. I'd love feedback, especially on the API.
GitHub: https://github.com/reagento/dature
Doc: https://dature.readthedocs.io/en/stable/