Typed config reader for resolved Coffer config files.
Coffer is a Go CLI that merges YAML configs, resolves secrets from GCP Secret Manager, and outputs a resolved config file. This library reads those pre-resolved files and provides ergonomic, type-safe access. No secret resolution, no GCP dependency.
pip install coffer-configfrom coffer import Config
# Load from a resolved config file (JSON or YAML)
config = Config.from_file("config.json")
# Dot-notation access
host = config.get("database.host")
port = config.get("database.port", type=int)
debug = config.get("debug", default=False, type=bool)
# Dict-style access (nested dicts become Config objects)
db = config["database"]
db["host"] # "localhost"
# Membership and iteration
"database.host" in config # True
list(config) # top-level keys
# Raw dict
config.to_dict()- Dot-separated keys: Keys containing literal dots (e.g.
{"a.b": 1}) are not accessible via dot-notation. Useconfig.to_dict()to access them directly.
The type= parameter on get() coerces values:
type= |
Behavior |
|---|---|
int |
int(value) |
float |
float(value) |
bool |
"true"/"1"/"yes" -> True, "false"/"0"/"no" -> False (case-insensitive) |
str |
str(value) |
list |
If string, splits on , and strips whitespace. Lists pass through. |