Configuration framework in Python for general configuration use.
Project description
Alchemy Config
The aconfig library provides simple yaml configuration in python with environment-based overrides.
Library advantages
- Easily reads environment variables with error handling, e.g. for absence of variables or boolean capitalization
- Allows users to easily access and traverse nested configuration without checking for key presence on every access
- Automatically handles overriding logic - environment variables take precedence over local configuration files
Installation
To install, simply use pip
pip install alchemy-config
Quick Start
config.yaml
foo: 1
bar:
baz: "bat"
main.py
import aconfig
if __name__ == "__main__":
config = aconfig.Config.from_yaml("config.yaml")
print(config.foo)
print(config.bar.baz)
export BAR_BAZ="buz"
python3 main.py
Corner-case Behavior
You CAN set builtin method names as attributes on the config. However, you should only access/delete them via dictionary access methods.
For example:
import aconfig
cfg = {"update": True}
config = aconfig.Config(cfg)
# DO NOT DO THIS:
config.update
# DO THIS INSTEAD:
config["update"]
This is because there is no way in Python to tell whether you want the method or the attribute "update" when "getting" it from the object.
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 alchemy_config-1.2.0.tar.gz.
File metadata
- Download URL: alchemy_config-1.2.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cb18d2076744750155b510a1ade8bdb3ed61623292b8a6acc85f30a6842eb81
|
|
| MD5 |
f4d87d3d02eac2c3956a57de02d41d18
|
|
| BLAKE2b-256 |
726da24deb3dbc2e0fb16f7e2b4b3fbd9ec68c2812dde2f2f8205302665af9ee
|
File details
Details for the file alchemy_config-1.2.0-py3-none-any.whl.
File metadata
- Download URL: alchemy_config-1.2.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b27e6a5782f1e597cfb24744ca7efbbcce22e4723cdbfa9e821e951276a539c
|
|
| MD5 |
37bf67c197b5ef615279332b05aded75
|
|
| BLAKE2b-256 |
9fa0d91b3e2cc3af68e264c827b3fadfb273ffa044cb1b1e253cecbfb3f0a6a8
|