Registry / serialization / yaml-config

yaml-config

JSON →
library0.1.5pypypi✓ verified 22d ago

Python client for reading YAML based config files. It provides a `Config` class for retrieving configuration variables from YAML files. It allows configuration of root and directory paths via environment variables. The library is currently at version 0.1.5 and has a low-cadence release cycle, with the last PyPI release in June 2020.

pip install yaml-config
INSTALL
IMPORT
SIG · YAML-CONFIG
Y
yaml-config
serializationpythonv0.1.5
Install
1.9s avg
Import
148ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.152s · 20MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.9s · import 0.144s · 21MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Config
from yamlconf import Config
from yaml_config import Config

This quickstart demonstrates how to create a `Config` subclass to load a YAML file and access its properties. It shows how to define a `default_file` and access nested configurations.

import os from yaml_config import Config # Create a dummy config file for the example config_content = """ database: host: localhost port: 5432 logging: level: INFO """ with open("my_app_config.yaml", "w") as f: f.write(config_content) # You can optionally set environment variables to define config root/dir # For example, in your shell: export MYAPP_CONFIG_ROOT=/tmp # This example assumes the file is in the current working directory. class MyAppConfig(Config): # Define the default config file name to be loaded default_file = 'my_app_config.yaml' # If using environment variables for root/dir, define a prefix: # default_env_prefix = 'MYAPP' # Would look for MYAPP_CONFIG_ROOT / MYAPP_CONFIG_DIR # Load the configuration config = MyAppConfig() # Access configuration values print(f"Database Host: {config.database.host}") print(f"Database Port: {config.database.port}") print(f"Logging Level: {config.logging.level}") # Clean up dummy config file os.remove("my_app_config.yaml")
Debug
Known issues
breakingOlder versions of `yaml-config` (prior to 0.1.3) might have used `PyYAML`'s `yaml.load()` function without explicitly specifying a `Loader` parameter. This usage is considered unsafe and was deprecated in `PyYAML` 5.1+, leading to a `TypeError` in `PyYAML` 6.0+.
fix
Upgrade to `yaml-config` version 0.1.3 or higher, which internally defaults to `yaml.SafeLoader` to mitigate this issue. If direct `PyYAML` interaction in your application is necessary and upgrade is not possible, explicitly pass `Loader=yaml.SafeLoader` to `yaml.load()` to prevent errors and enhance security.
affects: <0.1.3
gotchaThe `yaml-config` library supports configuring root and directory paths for config files using environment variables (e.g., `<prefix>_CONFIG_ROOT`, `<prefix>_CONFIG_DIR`). However, it does not natively provide functionality for interpolating environment variables *within* the YAML file content itself (e.g., `api_key: ${API_KEY}`).
fix
If you require environment variable interpolation for values inside your YAML content, consider pre-processing your YAML files (e.g., using Python's `os.path.expandvars` on the file content before passing it to `yaml-config`) or explore alternative YAML libraries that explicitly support this feature.
affects: All versions
gotchaUsing `yaml.load()` directly from `PyYAML` without specifying a safe loader (like `yaml.SafeLoader` or `yaml.FullLoader`) is a known security vulnerability, as it can execute arbitrary Python code. Although `yaml-config` versions 0.1.3+ default to `yaml.SafeLoader` for its internal loading, direct interactions with `PyYAML` in your own code should always prioritize safety.
fix
Always use `yaml.safe_load()` or explicitly pass `Loader=yaml.SafeLoader` when loading YAML from untrusted sources, even if `yaml-config` handles its internal loading safely.
affects: All versions (general PyYAML usage)
Upgrade
Version history
0.1.5latest on PyPI · released Jun 22, 2020
Audit
Dependencies
pyyamlrequiredCore dependency for YAML parsing and serialization.
Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources
yaml-config — pip install yaml-config · libregistry