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:
- Getting started
- How-to guides — recipes for the common tasks
- Reference — Field options, type hints, exceptions
- API reference — auto-generated from docstrings
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file env_proxy-1.6.0.tar.gz.
File metadata
- Download URL: env_proxy-1.6.0.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.14.5 Linux/6.17.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e74e09a94da212733dea43d3ced0b58ef7cc8baa9f2cc30bff17b65d1b967377
|
|
| MD5 |
d0621078ad34f6223fe76931be2953dd
|
|
| BLAKE2b-256 |
950fc0ec8bf35b0a9601347975b1c39c63a53563a8d09333f48f6430129f778b
|
File details
Details for the file env_proxy-1.6.0-py3-none-any.whl.
File metadata
- Download URL: env_proxy-1.6.0-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.5 Linux/6.17.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07c220f05b274774a2725f15ebb808e2a84db34e7aad821ed50527233dceb930
|
|
| MD5 |
b8960119dfaadc059928b4324ce40826
|
|
| BLAKE2b-256 |
cd11fefe52941a2003a3fac70454b2a96f1e799e7db5a2e351a13aec1ff7a3fd
|