Skip to main content

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 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 class
  • show - function that shows a list of environment variables used by the passed class
  • read_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

simple_dataclass_settings-0.0.3.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file simple_dataclass_settings-0.0.3.tar.gz.

File metadata

File hashes

Hashes for simple_dataclass_settings-0.0.3.tar.gz
Algorithm Hash digest
SHA256 34c2e5aeaf3963c0defaaa197b5783089bdaed6f5632432e1b140688e3caec87
MD5 38dcb1383418ef4a644dda4a761df99a
BLAKE2b-256 2ddde38bdb4ad4ac2736ac8ec4d238e8cf25ac02d146fd06a51197b21b66b48a

See more details on using hashes here.

File details

Details for the file simple_dataclass_settings-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_dataclass_settings-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8cfaaf287c0b75c2a9cd80c327a5d2c0f5f8fcfec4395b1fb8528587b59386d7
MD5 090dccebb260c7487d5aa1f950338fc3
BLAKE2b-256 29beb999d2f4607a536f7519a7f9265e32f76f891721dc12b5f13bb1a6517d0d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page