A minimal Python library to validate environment variables at startup. Zero dependencies.
Project description
envgate
A minimal Python library to validate environment variables at startup. Zero dependencies.
Why?
Instead of your app crashing at runtime because DATABASE_URL is missing,
envgate validates everything at startup and tells you exactly what's wrong.
Installation
pip install envgate
Quick Start
from envgate import get_env, validate
# Get a single variable with type coercion
port = get_env("PORT", type="int", default=8000)
debug = get_env("DEBUG", type="bool", default=False)
# Or validate multiple variables at once
config = validate({
"DATABASE_URL": {"type": "str"},
"REDIS_URL": {"type": "str"},
"PORT": {"type": "int", "default": 8000},
"DEBUG": {"type": "bool", "default": False},
})
If DATABASE_URL and REDIS_URL are missing and PORT is invalid, you get all errors at once:
envgate.exceptions.ValidationError: Environment validation failed:
- Environment variable 'DATABASE_URL' is not set.
- Environment variable 'REDIS_URL' is not set.
- Environment variable 'PORT' has invalid value 'abc' (expected int).
Supported Types
| Type | Example values |
|---|---|
str |
Any string (default) |
int |
"42", "-7", "0" |
float |
"3.14", "42", "-2.5" |
bool |
"true", "1", "yes", "on" / "false", "0", "no", "off" |
Contributing
Contributions are welcome! Check out the CONTRIBUTING.md for guidelines.
License
MIT
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
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 envgate-0.3.0.tar.gz.
File metadata
- Download URL: envgate-0.3.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dab82d02f631b5f9d8b411972f297063a7bc2e8f026196bfd09813b1aa473d3
|
|
| MD5 |
046844b1bad7e42f3388071300c9fd67
|
|
| BLAKE2b-256 |
98d66bbaf88938bef89a82332e8bf22377521f9016e2cb680918b7177918195e
|
File details
Details for the file envgate-0.3.0-py3-none-any.whl.
File metadata
- Download URL: envgate-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d4963a9cb49b0d8365429c1cc7bce977dd3c6fd5a8432488210cb2080991892
|
|
| MD5 |
ea8340052dc399314cb8cdcd8378a1a7
|
|
| BLAKE2b-256 |
fcbbba1842f4807816c7040c5cc361fc79a4931a2a611f30b16250e13c039f70
|