Simple library on top of dataclasses to create shiny-looking configs from environment variables.
Project description
simple_dataclass_settings
Simple library on top of dataclasses to create shiny-looking configs from environment variables.
Example usage
import simple_dataclass_settings
@simple_dataclass_settings.settings
class SomeChildSettings:
some_float: float = simple_dataclass_settings.field.float(
var='SOME_FLOAT',
)
@simple_dataclass_settings.settings
class Settings:
some_child: SomeChildSettings
some_string: str = simple_dataclass_settings.field.str(
var='SOME_STRING',
default='test',
)
some_number: int = simple_dataclass_settings.field.int(
var='SOME_NUMBER',
default=69,
)
some_flag: bool = simple_dataclass_settings.field.bool(
var='SOME_FLAG',
default=False,
)
some_list: bool = simple_dataclass_settings.field.str_list(
var='SOME_LIST',
default=['test', 'vars'],
)
settings = simple_dataclass_settings.populate(Settings)
Interface
settings- decorator that converts a class to the settings class (just a regular frozen (and slotted) dataclass)field- class that creates a special setting field object (that holds metadata about environment variables and its processing)populate- function that creates an instance of passed settings classshow- function that shows a list of environment variables used by the passed classread_envfile- function that populates variables from the env file
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 simple_dataclass_settings-0.0.5.tar.gz.
File metadata
- Download URL: simple_dataclass_settings-0.0.5.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbcaaefe857b665557cd16e5dd3eff1c45081428a4b1e2edd39127ed4b7e798d
|
|
| MD5 |
5d2c8b75dbac3311ad253ea64519409b
|
|
| BLAKE2b-256 |
4ce370163cac41bddf520bf560e55b09c477aab59ba2bec8f435fe63675f5bca
|
File details
Details for the file simple_dataclass_settings-0.0.5-py3-none-any.whl.
File metadata
- Download URL: simple_dataclass_settings-0.0.5-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a9f98c7b6b6ca079647aa8db2155ffd6130bdfa2160c75f4839f5ffac67b053
|
|
| MD5 |
30545722e0dc5f3a8ed8d479ab0af846
|
|
| BLAKE2b-256 |
f1fd59fe53c53e442cc8aade6535ba1357fb1a07076933650b5919d41a3ceb9b
|