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 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 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.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for simple_dataclass_settings-0.0.2.tar.gz
Algorithm Hash digest
SHA256 6bc11987458f1467790629e45edcb432e9064ce2385295b00df8315eecef2570
MD5 2bcf39368009c7a0bcbc53bf6617ad20
BLAKE2b-256 698ca9ec59c242286a83a6f030af56fb94bcab0cedd0b3c6f77d69a14e2ccf5a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simple_dataclass_settings-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c67866e219e8c3597d620e922feea99e18b54fbb589062c3f1760e1839181298
MD5 c210fc5b718975e03268e71ee84a9817
BLAKE2b-256 1e293d44e1b4fdc4a589157072c5321ca4fa7ab061b2026e2b421bb940c20451

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