Skip to main content

Manage python application config with ease.

Project description

quicksettings

A zero dependency package to manage python application configuration.

Installation

pip install quicksettings

Getting started

from dataclasses import InitVar, dataclass

from quicksettings import BaseSettings


@dataclass(init=False)
class Settings(BaseSettings):
    env_prefix: InitVar[str] = "FOO_"

    USERNAME: str
    PASSWORD: str = "slightly-secret"


settings = Settings()

The snippet above will set the value of settings.USERNAME to the value of the FOO_USERNAME environment variable. settings.PASSWORD will default to the supplied value if the related environment variable is not set. Thus, environment variables take precedence over defaults.

If fields with no defaults are declared without corresponding environment variables, an exception will be raised.

Supported field types

  • str
  • int
  • float
  • bool
  • list
  • dict

list and dict types can even contain each other, nested.

Known limitations

  • Since we're working with vanilla dataclasses, values with defaults cannot be defined before values without defaults. If your application is running python >= 3.10, the dataclass kw_only arg can be supplied.
  • While basic container types are supported (list & dict), nested dataclasses are not.
  • No dotenv support - it's up to you to set up the environment.
  • Field names are case sensitive by default
  • Union field types other than <type> | None might bug out, not sure if there's a use case for this.

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

quicksettings-0.2.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

quicksettings-0.2.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file quicksettings-0.2.0.tar.gz.

File metadata

  • Download URL: quicksettings-0.2.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for quicksettings-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d74df7900fcf3b27c68d177f979a99fd36995d003c3dd7d83667bea3b1d611f5
MD5 8f04fc373a5eac6ff03264150b8913ec
BLAKE2b-256 245aa7c34b8d6e458a7676256d4656f4c00491409969e35047c7ceb53a345139

See more details on using hashes here.

File details

Details for the file quicksettings-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: quicksettings-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for quicksettings-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 741087856e0fa56fdc94b7e8f52c75882c9b46297a97179dc38855121387a2df
MD5 3bec53fbfc68a1acc1c937be692f50b5
BLAKE2b-256 42ff4e739ed8002ac60c5a708e853604c0b33dd46cfb35b0fa1aa600e9345f61

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