Validate environment variables at startup — fail fast with clear errors.
Project description
env-sentinel
Validate environment variables at startup — fail fast with clear errors.
Most apps read environment variables scattered throughout the codebase. When one is missing or mistyped, the failure surfaces at runtime — often deep in a request handler, minutes or hours after startup. env-sentinel moves that failure to the very beginning: call require() once at startup with your expected variables and types, and get a single, readable error listing every problem before your app ever handles traffic.
Install
pip install env-sentinel
Usage
from env_sentinel import require
config = require({
"DATABASE_URL": str,
"PORT": int,
"DEBUG": bool,
"THRESHOLD": float,
})
# config["PORT"] is already an int, config["DEBUG"] is already a bool
If anything is wrong, you get a single EnvironmentError listing all failures:
EnvironmentError: Environment validation failed:
- PORT: missing
- DEBUG: cannot convert 'maybe' to bool (accepted: true/1/yes or false/0/no)
Supported types
| Type | Example env value | Python value |
|---|---|---|
str |
hello |
"hello" |
int |
8080 |
8080 |
float |
0.75 |
0.75 |
bool |
true / 1 / yes |
True |
bool |
false / 0 / no |
False |
Bool matching is case-insensitive.
License
MIT
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_sentinel-0.1.2.tar.gz.
File metadata
- Download URL: env_sentinel-0.1.2.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90ecc8f99071f5f104218c20960dca94bff96eafd2fc105adbf7f4f1b8b47a89
|
|
| MD5 |
fcd61e73bd50f7c69bc224791164cefd
|
|
| BLAKE2b-256 |
34353c8fdb6cb328f17ee49cadc29319c01419690fb61f7b816f1c03cfc1d51a
|
File details
Details for the file env_sentinel-0.1.2-py3-none-any.whl.
File metadata
- Download URL: env_sentinel-0.1.2-py3-none-any.whl
- Upload date:
- Size: 2.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
454eef7a46fc916cdc7f861962f5092698c56cbc0526d3b7f2629f0a65a3ce1c
|
|
| MD5 |
caa16de4472518882af47e60454de8fa
|
|
| BLAKE2b-256 |
8ca514c7f1a2db84a3c005ebb70065f07339c9d3df3fe39e5b7c6f562f373d66
|