https://github.com/dipendrapant/dotenvcheck
A package to cross-checks the environment variables used in your Python code against those declared in your .env and docker-compose.yml files.
https://github.com/dipendrapant/dotenvcheck
docker-compose environment environment-variables python3
Last synced: about 2 months ago
JSON representation
A package to cross-checks the environment variables used in your Python code against those declared in your .env and docker-compose.yml files.
- Host: GitHub
- URL: https://github.com/dipendrapant/dotenvcheck
- Owner: dipendrapant
- License: other
- Created: 2025-10-22T21:12:53.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-10-23T03:30:15.000Z (8 months ago)
- Last Synced: 2025-10-23T04:14:20.031Z (8 months ago)
- Topics: docker-compose, environment, environment-variables, python3
- Language: Python
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
`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
```bash
pip install dotenvcheck
# or
pipx install dotenvcheck
# with docker-compose support
pip install "dotenvcheck[compose]"
```
---
## Usage
From your project root (where `.env` lives):
```bash
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`.
```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.