Skip to content

env-proxy

PyPI version Python versions License CI Coverage

env-proxy reads environment variables with type hints, type conversion, and a declarative config layer. Define your environment-driven configuration once as a typed class, then access fields like any other attribute — with eager validation, optional freezing, and sample .env generation included.

Quickstart

import os
from env_proxy import EnvConfig, Field

os.environ["MYAPP_DEBUG"] = "true"
os.environ["MYAPP_DATABASE_URL"] = "sqlite:///data.db"
os.environ["MYAPP_CACHE_BACKENDS"] = "redis,memcached"

class MyConfig(EnvConfig):
    env_prefix: str = "MYAPP"
    debug: bool = Field(description="Enable debug mode", default=False)
    database_url: str = Field(description="Database connection URL")
    cache_backends: list[str] = Field(description="Cache backends", type_hint="list")

config = MyConfig()

print(config.debug)            # True
print(config.database_url)     # "sqlite:///data.db"
print(config.cache_backends)   # ["redis", "memcached"]

Where to go next

The documentation is organised by the Diátaxis framework:

Install

pip install env-proxy
# or
poetry add env-proxy