ClassyConfig is a Python3 package aiming to remove the need for a config.py or settings.py file.
Project description
ClassyConfig
ClassyConfig
is a Python3 package aiming to remove the need for a config.py
or settings.py
file.
from classy_config import BaseModel, ClassyConfig, ConfigParam
# Create your global config manager (example test-config.json below)
config = ClassyConfig(config_file="test-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.2.0a1.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for classy_config-0.2.0a1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0d8a2c04b8260d874642a45ddf34a84ce4a06a0f9323acaf8458890e87dc90d |
|
MD5 | 8abcc92a9cc2a3ef14468b4b46dabc06 |
|
BLAKE2b-256 | b4a70800660f16660dcb2ae4b5d8b6a37e16172b28fbae3832d400c6a1e332ec |