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
strintfloatboollistdict
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_onlyarg 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> | Nonemight 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quicksettings-0.1.0.tar.gz.
File metadata
- Download URL: quicksettings-0.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60e710032d7c019e7a79cd6e20296bac7093f9e6695b9232042d30cbb18d3d52
|
|
| MD5 |
2f107a27fc8548677283b22702f09b5a
|
|
| BLAKE2b-256 |
f1029a8876ab5c20f00bfbfbd8f7fb4b55dcb8239d9f801def37f21892d7ecbc
|
File details
Details for the file quicksettings-0.1.0-py3-none-any.whl.
File metadata
- Download URL: quicksettings-0.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee28b80bb6c7f878167e5b7c99ecc7caeeeda31d722a2597c8350ba81552690d
|
|
| MD5 |
7eb27df8559c838bd8d7b1f922173421
|
|
| BLAKE2b-256 |
c939e0902b42d53aeceb23f03979a4f4ba477ed82d56415be1414f858f4c715e
|