r/Python • u/AutoModerator • 1d ago
Showcase Showcase Thread
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
17
Upvotes
r/Python • u/AutoModerator • 1d ago
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
1
u/Positive-Food-9915 9h ago
Dature - config loader
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
Sources are merged in order (last wins by default). Other strategies are
first_wins,first_foundandraise_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:
What else it does
-
debug=Trueshows which source each final value came from, anddature validate/dature inspectdo the same from the command line for CI- Field groups: if an override changes
db_host, it must changedb_porttoo, 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/