Skip to main content

Settings management using environment variables and type annotations.

Project description

Envotate

Work in progress

Settings management using environment variables and type annotations. This intended to support both class-based and module-based configurations.

Example

Define a configuration like this:

# app/settings.py
from envotate.env import Env, env
from envotate.types import Choice, Default


@env
class Database:
    DB_USER: str
    DB_PASSWORD: str
    DB_HOST: str
    DB_PORT: int
    DB_NAME: str


PY_39 = "py39"
PY_310 = "py310"


@env
class Settings:
    DATABASE: Database
    DEBUG: bool = False
    PY_VERSION: Env[str, Choice([PY_39, PY_310]), Default(PY_39)]

Then access it in an application:

# app/main.py
from app.settings import Settings


def main():
    print(Settings.DATABASE.DB_NAME)


if __name__ == "__main__":
    main()

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

envotate-0.0.1.tar.gz (8.4 kB view hashes)

Uploaded Source

Built Distribution

envotate-0.0.1-py3-none-any.whl (10.4 kB view hashes)

Uploaded Python 3

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