yi-config-starter
A lightweight YAML configuration loader with automatic config discovery, placeholder substitution, and a thread-safe singleton interface.
This library is intended to centralize configuration loading logic while keeping application code clean and portable across environments.
Installation
pip install yi-config-starter
Quick Start
from yi_config_starter import ApplicationConfiguration
cfg = ApplicationConfiguration.get_instance()
config = cfg.get_config()
db_host = cfg.get_config_value("db.datasource.config.host")
print(db_host)
You may also initialize it explicitly (still resolves to a singleton internally):
from yi_config_starter import ApplicationConfiguration
cfg = ApplicationConfiguration(
filename="config.yml",
env_var="MY_APP_CONFIG",
app_name="my-app",
# path="/absolute/or/~/path/to/config.yml",
# extra_placeholders={"PROJECT_ROOT": "/some/path"},
)
Configuration File Discovery
By default, the loader searches for config.yml in the following order:
-
Explicit path passed to the constructor (
path=...) -
Path provided via environment variable
-
Current working directory, then parent directories (walking upward)
-
User configuration directory
- Windows:
%APPDATA%\<app_name>\config.yml - Linux/macOS:
~/.config/<app_name>/config.yml
- Windows:
-
Entries on
sys.path(recursive search)
If no configuration file is found, a FileNotFoundError is raised.
Placeholder Substitution
Before parsing YAML, placeholders in the configuration file are substituted.
Built-in Placeholders
| Placeholder | Description |
|---|---|
{{HOME}} |
User home directory |
{{separator}} |
OS path separator (/ or \\) |
{{APPDATA}} |
Windows %APPDATA% or fallback to ~/.config |
{{XDG_CONFIG}} |
$XDG_CONFIG_HOME or ~/.config |
{{ENV:VAR_NAME}} |
Value of environment variable VAR_NAME (case-insensitive: ENV/env; if missing, it is reported in the unresolved placeholder error) |
Custom placeholders may be supplied via extra_placeholders.
Unresolved placeholders
After preprocessing, if any {{...}} placeholders remain unresolved, a ValueError is raised listing all unresolved placeholder names.
Example
paths:
data_dir: "{{HOME}}{{separator}}data"
cache_dir: "{{XDG_CONFIG}}{{separator}}my-app{{separator}}cache"
# ENV token is case-insensitive, so {{env:...}} also works:
api_key: "{{env:MY_API_KEY}}"
API Reference
ApplicationConfiguration.get_instance(...)
Returns the singleton configuration instance (thread-safe).
cfg.get_config() -> dict
Returns the entire configuration as a dictionary.
cfg.get_config_value("a.b.c")
Returns a nested configuration value using dot-separated keys.
ApplicationConfiguration.get_value_from_config(config: dict, key: str)
Static helper for retrieving nested values from an arbitrary dictionary.
Versioning
The package version is resolved dynamically from:
import yi_config_starter
yi_config_starter.__version__
Defined in:
/yi_config_starter/__init__.py
License
MIT License — see the LICENSE file.
Metadata
Release files for yi-config-starter 0.2.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 |
|---|---|---|---|---|
| yi_config_starter-0.2.2.tar.gz | 7.0 kB | Without provenance | Details for yi_config_starter-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yi_config_starter-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for yi_config_starter-0.2.2-py3-none-any.whl |
Total release size: 14.5 kB
Release files / yi_config_starter-0.2.2.tar.gz
| Download URL | yi_config_starter-0.2.2.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd10edefd5f38d6588e6ce5547152d49733101f350d403b8a5b923b6a3beced1
|
|
BLAKE2b-256 checksum How to use checksums |
9e74f8120c1d1e2d570f34d95aab2fd88db4514c4ba0370253f57f8beba92ca1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / yi_config_starter-0.2.2-py3-none-any.whl
| Download URL | yi_config_starter-0.2.2-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
60d70ef3d4fa1ec7e9a20d582d1c1f1855dd45665d62f2906ea0f6023b13fc27
|
|
BLAKE2b-256 checksum How to use checksums |
9bb11e0f02332bfc9e88fd9c406f08d1aac2ebde58fca24a1952b370287d4dd5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for yi-config-starter 0.2.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.