Skip to main content

Cross-check environment variables used in Python code against .env and docker-compose.

Project description

dotenvcheck cross-checks the environment variables used in your Python code against those declared in your .env and docker-compose.yml files. It reports unused, missing, and mismatched variables — helping you keep your environment configuration clean and consistent.

For example, if you’ve ever had a project with 20 variables in .env but only 10 actually used, dotenvcheck instantly shows you which ones can be safely removed or fixed.


Installation

pip install dotenvcheck
# or
pipx install dotenvcheck

# with docker-compose support
pip install "dotenvcheck[compose]"

Usage

From your project root (where .env lives):

dotenvcheck .

You’ll get a report listing missing, unused, or suspicious environment variables.

Example output:

== dotenvcheck report ==
unused (2): DATABASE_URL, NOTUSEDAPI_KEY

sources:
  API_KEY: .env
  DATABASE_URL: .env
  DEBUG: .env
  NOTUSEDAPI_KEY: .env

Configuration (optional)

You can configure defaults globally for your project via a [tool.dotenvcheck] section in your pyproject.toml.

[tool.dotenvcheck]
exclude = [".venv", "venv", "env", ".git", "__pycache__", "dist", "build", "node_modules"]
fail_on = ["missing"]
dotenv = ".env"
include = "*.py"

Options

Key Type Default Description
exclude list of strings [".venv", "venv", "env", ".git", "__pycache__", "dist", "build", "node_modules"] Directories or file patterns to ignore while scanning your code.
include string or list of strings "*.py" Glob pattern(s) of files to include when scanning for environment variable usage.
dotenv string ".env" Path to your .env file used for validation.
fail_on list of strings ["missing"] Determines which findings trigger a non-zero exit code. Options: "missing", "typos", "bad_values", "unused".

Behavior

  • Ignores common directories like .venv, dist/, build/, and .git/ by default.
  • Command-line arguments always override pyproject.toml.
  • Works seamlessly across macOS, Linux, and Windows.
  • Fully supports Python 3.8 → 3.12+.

Project structure

dotenvcheck/
├─ src/
│  └─ envguard/
│     ├─ __init__.py
│     ├─ __main__.py
│     ├─ cli.py
│     ├─ scanner.py
│     ├─ dotenv.py
│     ├─ compose.py
│     └─ report.py
├─ tests/
├─ pyproject.toml
├─ LICENSE
├─ README.md
└─ .github/
   └─ workflows/
      ├─ test.yml
      └─ workflow.yml

License

MIT License – feel free to use, modify, and contribute.

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

dotenvcheck-0.1.9.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

dotenvcheck-0.1.9-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file dotenvcheck-0.1.9.tar.gz.

File metadata

  • Download URL: dotenvcheck-0.1.9.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dotenvcheck-0.1.9.tar.gz
Algorithm Hash digest
SHA256 36bd6474b9cbe9248d9d45d2cd9074d9690ca0e251682533ba478e0ea02c9a30
MD5 6099522c4e068fc286d4af899be942df
BLAKE2b-256 21627265a7e561f837cadbc17dc98424222558930698d50dc9f27ad913c79bb1

See more details on using hashes here.

Provenance

The following attestation bundles were made for dotenvcheck-0.1.9.tar.gz:

Publisher: workflow.yml on dipendrapant/dotenvcheck

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dotenvcheck-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: dotenvcheck-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dotenvcheck-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 58af6b1c90e387ce88d2cabdce6ac20a4bbc0f761fd8ecc90cad39154774b712
MD5 ed631d401cc6f0890859fb0e55606a47
BLAKE2b-256 85f1a9018a6393cb1a029f5d67180ff2582f717392ae1b6e7b8ba733ee7b7710

See more details on using hashes here.

Provenance

The following attestation bundles were made for dotenvcheck-0.1.9-py3-none-any.whl:

Publisher: workflow.yml on dipendrapant/dotenvcheck

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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