Skip to main content

A minimal Python library to validate environment variables at startup. Zero dependencies.

Project description

envgate

CI codecov PyPI version Python License: MIT

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)

# Explicitly mark a variable as required
api_key = get_env("API_KEY", required=True)

# 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

envgate-0.4.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

envgate-0.4.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file envgate-0.4.0.tar.gz.

File metadata

  • Download URL: envgate-0.4.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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

Hashes for envgate-0.4.0.tar.gz
Algorithm Hash digest
SHA256 3ee7965ee3b2fa97a490511a2d738b1a567d6bdb4a95aca9c430817d36901466
MD5 a7929e99748d255e33caaf46691b5204
BLAKE2b-256 5b59c09176302883b5b3c8e2ff17ec2e53b492179c484bf07721d353dd78032b

See more details on using hashes here.

File details

Details for the file envgate-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: envgate-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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

Hashes for envgate-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 58efe3a94b5e559488911da8f8528e2469732fd6b60228d656141f71e1523f45
MD5 415590a78784e11c2244b4d5359113e9
BLAKE2b-256 b7b5bc0700f1c2df652dd1987a2044e437a5c3f33f36837cff17176a8aea66be

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