Inject your config variables into methods, so they are as close to usage as possible.
Project description
ClassyConfig
Inject your config variables into methods, so they are as close to usage as possible.
from classy_config import BaseModel, ClassyConfig, ConfigParam
# Create your global config manager (example config.json below)
config = ClassyConfig(config_file="config.json")
# Resolve default values based on your config
def print_current_version(version: str = ConfigParam("version", str)) -> None:
print(version)
# Use Pydantic Models for your config
class Author(BaseModel):
username: str
email: str
lucky_number: int
# Resolve default values based on your config
def print_author(author: Author = ConfigParam("author", Author)) -> None:
print(author)
# Allows for nested values
def print_value(value: int = ConfigParam("nested.value", int)) -> None:
print(value)
{
"version": "0.0.1",
"author": {
"username": "GDWR",
"email": "gregory.dwr@gmail.com",
"lucky_number": 17
},
"nested": {
"value": 10
}
}
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
classy_config-0.1.1.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for classy_config-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afaa01e41d1d612f7d5b26c0ca99ef0a7cff7ba393cae1fe2e2ef98dcd1ecabc |
|
MD5 | 4a8da7e7c6c0d61fea787552311a36ce |
|
BLAKE2b-256 | 0aa27ad0fecf412b3244068fc6dc90692d9e409138b3aeaa71edde44c2903d13 |