No project description provided
Project description
simple_dataclass_settings
Simple library on top of dataclasses to create shiny-looking configs from environment variables.
Example usage
import dataclass_env
@dataclass_env.settings
class SomeChildSettings:
some_float: float = dataclass_env.field.float(
var='SOME_FLOAT',
)
@dataclass_env.settings
class Settings:
some_child: SomeChildSettings
some_string: str = dataclass_env.field.str(
var='SOME_STRING',
default='test',
)
some_number: int = dataclass_env.field.int(
var='SOME_NUMBER',
default=69,
)
some_flag: bool = dataclass_env.field.bool(
var='SOME_FLAG',
default=False,
)
some_list: bool = dataclass_env.field.str_list(
var='SOME_LIST',
default=['test', 'vars'],
)
settings = dataclass_env.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.2.tar.gz
.
File metadata
- Download URL: simple_dataclass_settings-0.0.2.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bc11987458f1467790629e45edcb432e9064ce2385295b00df8315eecef2570 |
|
MD5 | 2bcf39368009c7a0bcbc53bf6617ad20 |
|
BLAKE2b-256 | 698ca9ec59c242286a83a6f030af56fb94bcab0cedd0b3c6f77d69a14e2ccf5a |
File details
Details for the file simple_dataclass_settings-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: simple_dataclass_settings-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.2 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 | c67866e219e8c3597d620e922feea99e18b54fbb589062c3f1760e1839181298 |
|
MD5 | c210fc5b718975e03268e71ee84a9817 |
|
BLAKE2b-256 | 1e293d44e1b4fdc4a589157072c5321ca4fa7ab061b2026e2b421bb940c20451 |