Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

env_sentinel-0.1.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

env_sentinel-0.1.0-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file env_sentinel-0.1.0.tar.gz.

File metadata

  • Download URL: env_sentinel-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.9

File hashes

Hashes for env_sentinel-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5a5365eca655bde42c39a098ca044ad00aa392bf2461b23ac643e8af2649ecb2
MD5 2a3d06e24125bed1ade050359b56d3c8
BLAKE2b-256 0457521c4150306bef488098b4dae04c2fefd824f508b1cd70b07feb4584316d

See more details on using hashes here.

File details

Details for the file env_sentinel-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: env_sentinel-0.1.0-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.9.9

File hashes

Hashes for env_sentinel-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 45b4248e99b64b3d2c8e93c6c67365defebc5fe9c59696dcc32e78321fec36bc
MD5 32652918e36256288d7195cfc9e44ba4
BLAKE2b-256 72fe6f26c735c06b25efc11b15acb919f06da50fea60b458c528b0ef0365f134

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