Setting management library
Project description
Seth
A setting management library. By grouping all your application settings in one class, it's easier to document.
First, define a class for your settings. It must be a dataclass
(or even better,
a frozen dataclass
) and inherit from seth.Settings
.
from dataclasses import dataclass
from typing import Optional
from bl_seth import Settings
@dataclass
class MySettings(Settings):
MANDATORY: str
"A mandatory string."
DEFAULT: str = "default"
"""A string that defaults to '"default"'."""
INTEGER: int = 1
"An integer that defaults to '1'."
OPTIONAL: Optional[str] = None
"An optional value."
Then instantiate it using its from_dict
class method. Most probably, the dictionary
is built from the environment.
import os
settings = MySettings.from_dict(os.environ)
You can now directly access its attributes.
settings.DEFAULT == "default"
settings.OPTIONAL is None
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
bl_seth-0.1.2-py3-none-any.whl
(15.0 kB
view hashes)