Skip to main content

Creates a class used to query environmental variables with typehinting a conversion to basic Python types.

Project description

env-proxy

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

Install

# Using pip
pip install env-proxy

# Using Poetry
poetry add env-proxy

Supports Python 3.10+.

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()
config.validate()   # fail fast on missing/bad env values
config.freeze()     # optional: turn reads into a dict lookup

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

For one-off lookups without a full config class, the lower-level EnvProxy exposes typed getters (get_str, get_int, get_bool, get_list, get_json, …):

from env_proxy import EnvProxy

proxy = EnvProxy(prefix="MYAPP")
proxy.get_int("port", default=8080)

Documentation

Full documentation — tutorial, how-to guides, reference, and the auto-generated API — lives at https://tomasvotava.github.io/env-proxy/.

Quick links:

Contributing

make ci runs every check that CI runs (ruff format --check, ruff check, mypy, pytest). make docs-serve previews the docs at http://127.0.0.1:8000.

License

env-proxy is open-source under the MIT License. See LICENSE.md.

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

env_proxy-1.5.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

env_proxy-1.5.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file env_proxy-1.5.0.tar.gz.

File metadata

  • Download URL: env_proxy-1.5.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.4 Linux/6.17.0-1010-azure

File hashes

Hashes for env_proxy-1.5.0.tar.gz
Algorithm Hash digest
SHA256 28a405e245e8e6bb7a2ca236d6521ccbac912265c10e06e05570fddea545bad0
MD5 07d4398afe42eb69c9b85e49fd743fac
BLAKE2b-256 8da8ac1e681fa00f45c8baee524ea49fc3bdbba6e15e759d43418e0819accf98

See more details on using hashes here.

File details

Details for the file env_proxy-1.5.0-py3-none-any.whl.

File metadata

  • Download URL: env_proxy-1.5.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.4 Linux/6.17.0-1010-azure

File hashes

Hashes for env_proxy-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ca713744a8b4d2a241f3239a043b525068b13e95d9628caa0b69959759c19a39
MD5 9ea1c66f2ed77b9cdac6b8e3cdec9991
BLAKE2b-256 92e63430a6376429a0db7204dbb73a0cd31ef5538bb08bc5af83be3f5194309e

See more details on using hashes here.

Supported by

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