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.1.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.1-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

Hashes for env_sentinel-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4dabfb5e94e8d6603bd2ff4b3b882a0447abad9c51f78f78848bc6813d7c9059
MD5 2e6aaa72ed862aff828fb86416b297aa
BLAKE2b-256 04e4453386f14024ad27376f2b8e8da74d766401850efa26a3da03d1d01bdf36

See more details on using hashes here.

File details

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

File metadata

  • Download URL: env_sentinel-0.1.1-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

Hashes for env_sentinel-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 10626972b30ed6072390771055f8ba543bd323b12372b8738fd007c211e8cbab
MD5 4d7b437f749fc1ee51a342121dc26ae7
BLAKE2b-256 4ef9dd76f80a736fbcb1c0acc79bae8f63d71eb541e2b295887215557425dba3

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