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
File details
Details for the file simple_dataclass_settings-0.0.4.tar.gz
.
File metadata
- Download URL: simple_dataclass_settings-0.0.4.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a388af7ce2a6c58a41cf19c078ffc6bc1a839b1e16ece807b4e9c0b61377adf |
|
MD5 | b88ee12568d6dd0654d24513da7e4748 |
|
BLAKE2b-256 | e5d3781ffd49577536494128f0a414ca8328e6bc9560530ba811c416a8719344 |
File details
Details for the file simple_dataclass_settings-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: simple_dataclass_settings-0.0.4-py3-none-any.whl
- Upload date:
- Size: 5.3 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 | d7d5d9eb4ba906d1602602b048ddcb1f55be9fdeb35e3a3f03147624f482a1cd |
|
MD5 | f5478113f23f6fe87c284666b5200477 |
|
BLAKE2b-256 | 5424e8a6d46a9b450d8d413a46e91c8074c870d99e5800a752bfea240da9dff1 |