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

You can display the documentation for a setting class from the command line:

seth bl_seth.utils:DemoSettings

jedi needs to be available for variable documentation to be displayed. This can be done by installing seth[all] or jedi separately.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bl_seth-0.3.0.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

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

bl_seth-0.3.0-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file bl_seth-0.3.0.tar.gz.

File metadata

  • Download URL: bl_seth-0.3.0.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.12 Linux/7.0.10-gnu

File hashes

Hashes for bl_seth-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ac5bce87341a60407d7d40a97669e61c33b11f3e8932eb7c5256355e67897c46
MD5 7897ed7e53d38d489ae85961f652bf17
BLAKE2b-256 b0594699a0018a6efb495878790c538bd04387aa46a781fc93487b50c3c3b488

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bl_seth-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.12 Linux/7.0.10-gnu

File hashes

Hashes for bl_seth-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b75fb5539406779d7c4652b2277e1c2f30283fc8e9fc09054917af508e41870e
MD5 85b930de29330a516c6caa1528c59702
BLAKE2b-256 3750953d98adab6de31191a196dc1f91b5fb16e68477c50b64e02152ebb1bf26

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