Skip to main content

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


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

If you're not sure about the file name format, learn more about wheel file names.

bl_seth-0.1.2-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file bl_seth-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: bl_seth-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.9 Linux/6.1.7-gnu

File hashes

Hashes for bl_seth-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2a2a64aeda2e423e4831451c95fa91a93192e09b8e9736aa51d6f6821a659f11
MD5 562b4d3ba8dee5b15dadda5273c67d90
BLAKE2b-256 ed8cacb152d4bdca5fe42200ec17bdf9adfcddc2fca23fbe34c7ed3d775ca1c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page