Confetti 🎊
Settings that fit Confetti.
A tiny, dependency-light config loader for Python. Load YAML, JSON, or TOML and access values as attributes instead of dict lookups — with sane defaults, nested access, and clear errors when something's actually wrong.
cfg = confetti.load("settings.yaml")
cfg.database.host # not cfg["database"]["host"]
Author
Artheme Gauthier-Villars (agauthier@ethz.ch)
Why
Most config loaders make you choose between two annoying extremes: raw dict access (config["db"]["host"], brackets everywhere, KeyError the moment something's missing) or a heavyweight framework with a learning curve for a problem that shouldn't need one.
confetti sits in between:
- Dot access on nested config, including lists of objects
- Missing keys return
Noneinstead of crashing, so you can useor/.get()defaults freely - One format, three loaders — YAML, JSON, and TOML all produce the same
Configobject require()when you do want a hard failure for missing critical keys- Environment variable overlays for the classic "base config + secrets from env" pattern
- No magic — under 150 lines, easy to read in five minutes, easy to vendor if you don't want a dependency
Install
pip install confetti-config
(Import name is confetti; the PyPI name is confetti-config to avoid collisions.)
Quick start
# settings.yaml
app_name: MyService
debug: false
database:
host: localhost
port: 5432
timeout: 1e-3
servers:
- name: primary
region: us-east
- name: backup
region: eu-west
from confetti import load
cfg = load("settings.yaml")
cfg.app_name # "MyService"
cfg.database.host # "localhost"
cfg.database.timeout # 0.001 (scientific notation auto-coerced to float)
cfg.servers[0].region # "us-east"
cfg.nonexistent_key # None — no crash
Use cases
Application settings Load a single source of truth for your app and pass it around as one object instead of threading dict keys through every function signature.
cfg = load("config.yaml")
db = connect(host=cfg.database.host, port=cfg.database.port)
Layered config (base + environment overrides) Keep shared defaults in one file and override per-environment values in another.
base = load("base.yaml")
prod = load("prod.yaml")
cfg = base.merge(prod) # prod values win
Config from environment variables Useful in containerized deployments where secrets come from env, not files.
from confetti import Config
env_cfg = Config.from_env("APP_") # reads APP_HOST, APP_PORT, ...
cfg = base.merge(env_cfg)
Validating required settings on startup
Fail fast and loud instead of hitting an AttributeError three layers deep at runtime.
cfg.require("database", "secret_key")
# raises ConfigError listing exactly what's missing
Multi-format projects Same API regardless of which file format you're handed.
load("settings.yaml")
load("settings.json")
load("settings.toml")
API reference
| Method | Description |
|---|---|
load(path) / Config.load(path) |
Load a .yaml, .json, or .toml file into a Config |
Config.from_dict(d) |
Wrap an existing dict |
Config.from_env(prefix="") |
Build a Config from environment variables |
cfg.get(key, default=None) |
Attribute access with an explicit fallback |
cfg.require(*keys) |
Raise ConfigError if any key is missing |
cfg.merge(other) |
Return a new Config with other's values overlaid |
cfg.to_dict() |
Convert back to a plain nested dict |
key in cfg |
Membership check |
for key in cfg |
Iterate over top-level keys |
Error handling
All failures — missing files, bad syntax, unsupported formats, missing required keys — raise a single ConfigError, so you only need one except clause:
from confetti import load, ConfigError
try:
cfg = load("settings.yaml")
cfg.require("database", "api_key")
except ConfigError as e:
print(f"Config problem: {e}")
raise SystemExit(1)
What it's not
confetti doesn't do schema validation, type enforcement, hot-reloading, or secrets management. If you need any of those, look at pydantic-settings or dynaconf — they're great at it. confetti is for the much more common case: I have a config file and I want to use it without typing brackets.
License
MIT
Metadata
Release files for confetti-config 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| confetti_config-1.0.2.tar.gz | 7.3 kB | Without provenance | Details for confetti_config-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| confetti_config-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for confetti_config-1.0.2-py3-none-any.whl |
Total release size: 13.8 kB
Release files / confetti_config-1.0.2.tar.gz
| Download URL | confetti_config-1.0.2.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a8d9ad206f9365e85300c82c99626faf21c3ea2adc649dd4be9639f97584838
|
|
BLAKE2b-256 checksum How to use checksums |
6ba056bffd51f35fe41210a375bcfef408a1c4f571c1c52fe207d26264c56646
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Release files / confetti_config-1.0.2-py3-none-any.whl
| Download URL | confetti_config-1.0.2-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b703b58ce7e3d76e4e8a1c6623bfdaa38be91b2569f90418b593e0e402cb60b9
|
|
BLAKE2b-256 checksum How to use checksums |
84ca5e25556846d16d50388cfc141877cd584a95a78bc2597de4033f7b7c38da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Security for confetti-config 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.