Centralized YAML config loader with ease
Project description
yayaya
„Ja, ja, YAML schon wieder.“ — Every backend dev in Berlin, probably.
yayaya is a tiny helper for Yet Another YAml YArd (look, the letters lined up and we ran with it). It loads one YAML file—or several merged in order—lets you read nested keys with dot notation, and expands ${ENV_VAR} placeholders so secrets can live in the environment where they belong—not committed next to your instruction: prompts.
No framework. No magic beans. Just pyyaml and the sound of your PM saying jajaja when you tell them config is “basically done.”
Install
pip install yayaya
Or point pip at this repo if you live on the edge.
Quick start
from yayaya import init, get, contains
init("/path/to/config.yaml")
title = get("app.title", default="Untitled")
db_url = get("database.url", required=True)
if contains("features.experimental"):
...
Multiple files (layered config)
Pass a list: earlier files are the base, later ones override. Nested dicts are deep-merged; scalars and lists are replaced entirely by the newer file. Expansion runs once on the merged result.
init(["/etc/myapp/defaults.yaml", "/instance/config.yaml", "/instance/local.yaml"])
Useful for defaults + tenant config + secrets-by-path without copy-pasting huge trees.
${ENV_VAR} expansion
After parsing YAML, all strings are walked recursively. Placeholders like ${API_KEY} are replaced with values from os.environ. Missing variables become empty strings.
# config.yaml
service:
api_key: "${API_KEY}"
port: 8080
import os
from yayaya import init, get
os.environ["API_KEY"] = "secret"
init("config.yaml")
assert get("service.api_key") == "secret"
assert get("service.port") == 8080
You can also run expansion yourself (e.g. on a dict you built elsewhere):
from yayaya import expand_env_placeholders
data = expand_env_placeholders({"x": "${HOME}"}, environ=os.environ)
API
| Function | Purpose |
|---|---|
init(path) |
Load one YAML file, or init([p1, p2, ...]) to merge left → right. |
get(key, default=None, required=False) |
Dot-path lookup ("db.pool.size"). |
contains(key) |
Whether the path exists. |
reload_config() |
Re-read the same path(s) in the same order. |
override_config_path(path) |
Same as init (one path or a list). |
config_paths() |
Absolute paths last passed to init / override_config_path. |
deep_merge(a, b) |
Deep-merge two dict-like trees (lists replaced, not spliced). |
expand_env_placeholders(value, environ=None) |
Recursive ${VAR} substitution. |
Exceptions (all subclass ConfigError): ConfigNotLoadedError, ConfigFileNotFoundError, ConfigKeyNotFoundError.
Development
pip install -e ".[dev]"
python -m unittest discover -s tests -v
License
Whatever the repo owner says—ask Karel if you’re unsure.
If YAML were a conversation, yayaya is the part where you nod three times and actually read the file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yayaya-0.3.0.tar.gz.
File metadata
- Download URL: yayaya-0.3.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d1cde665bdc954a6027cc5abd217ebbeabb8cbdc59eb267f25afee76ad4d185
|
|
| MD5 |
b9860b99a4726d8a7e9fc6b1e63d02c0
|
|
| BLAKE2b-256 |
eb5a638f705fcef5baf04ae8a1283c4248d7f3e27ba5012aad1434e440ddb04e
|
Provenance
The following attestation bundles were made for yayaya-0.3.0.tar.gz:
Publisher:
publish.yml on KodzghlyCZ/python-yayaya
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yayaya-0.3.0.tar.gz -
Subject digest:
8d1cde665bdc954a6027cc5abd217ebbeabb8cbdc59eb267f25afee76ad4d185 - Sigstore transparency entry: 1486848074
- Sigstore integration time:
-
Permalink:
KodzghlyCZ/python-yayaya@c60c93850c337adb8a4eb9a2f63120ce4c75288e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/KodzghlyCZ
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c60c93850c337adb8a4eb9a2f63120ce4c75288e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file yayaya-0.3.0-py3-none-any.whl.
File metadata
- Download URL: yayaya-0.3.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d626648e23b962a4f8596e2b71cc29398021e4832fd70bca6e44fe438b0ca776
|
|
| MD5 |
2bd83edb5efea4382facc09e01700508
|
|
| BLAKE2b-256 |
2536174b5298ca9230657e842fb9e04ad83a123d37b025fb339468ce1e39b83b
|
Provenance
The following attestation bundles were made for yayaya-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on KodzghlyCZ/python-yayaya
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yayaya-0.3.0-py3-none-any.whl -
Subject digest:
d626648e23b962a4f8596e2b71cc29398021e4832fd70bca6e44fe438b0ca776 - Sigstore transparency entry: 1486848133
- Sigstore integration time:
-
Permalink:
KodzghlyCZ/python-yayaya@c60c93850c337adb8a4eb9a2f63120ce4c75288e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/KodzghlyCZ
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c60c93850c337adb8a4eb9a2f63120ce4c75288e -
Trigger Event:
workflow_dispatch
-
Statement type: