Skip to main content

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

Project description

env-proxy

PyPI version Python versions License CI Coverage

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.

Commit messages follow Conventional Commits; the pre-commit commit-msg hook enforces this locally.

Releasing

Releases are driven by commitizen. From master:

poetry run cz bump      # bumps pyproject.toml, appends to CHANGELOG.md, commits, tags
git push --follow-tags  # pushes the bump commit and the new tag together

Pushing the tag triggers .github/workflows/release.yml, which builds the distribution, creates a GitHub Release whose body is the matching CHANGELOG.md section, and publishes to PyPI.

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.6.1.tar.gz (15.7 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.6.1-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: env_proxy-1.6.1.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.6 Linux/6.17.0-1018-azure

File hashes

Hashes for env_proxy-1.6.1.tar.gz
Algorithm Hash digest
SHA256 2538beff350c5f926e3de5bb9918d9bc8d8f8cbb595075896ccac8f827ed6d24
MD5 51073fff8885006bbb3b7a7602ac104e
BLAKE2b-256 78184dc015b0b0e23f8a7653ed6b4ceb9dbf4cd5fff0598d03b5f06845c70d05

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for env_proxy-1.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 780877ebcb8c198e3af86ea20f7bca7021a701a8bf325ce255bd4700c0216c0a
MD5 a6534b8c461cfeaa84254b7a92aa0703
BLAKE2b-256 f06df6d1c52f6f00226db79c2b294def3094e8af16256c928108849638d3efa3

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