You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project cross-check environment variables used in your Python code against declarations in `.env` and `docker-compose.yml`. And gives the report showing the list of unused environment variable. It is a great package at least i was waiting for a long time.
1
+
`envguard` cross-checks the environment variables used in your Python code against those declared in your `.env` and `docker-compose.yml` files.
2
+
It reports **unused**, **missing**, and **mismatched** variables — helping you keep your environment configuration clean and consistent.
2
3
3
-
## Install
4
+
For example, if you’ve ever had a project with 20 variables in `.env` but only 10 actually used, `envguard` instantly shows you which ones can be safely removed or fixed.
4
5
5
-
````bash
6
-
pipx install envguard
7
-
# or
6
+
---
7
+
8
+
## Installation
9
+
10
+
```bash
8
11
pip install envguard
9
-
# docker-compose extras:
12
+
# or
13
+
pipx install envguard
14
+
15
+
# with docker-compose support
10
16
pip install "envguard[compose]"
17
+
```
18
+
19
+
---
20
+
21
+
## Usage
22
+
23
+
From your project root (where `.env` lives):
24
+
25
+
```bash
26
+
envguard .
27
+
```
28
+
29
+
You’ll get a report listing missing, unused, or suspicious environment variables.
30
+
31
+
Example output:
32
+
33
+
```
34
+
== envguard report ==
35
+
unused (2): DATABASE_URL, NOTUSEDAPI_KEY
36
+
37
+
sources:
38
+
API_KEY: .env
39
+
DATABASE_URL: .env
40
+
DEBUG: .env
41
+
NOTUSEDAPI_KEY: .env
42
+
```
43
+
44
+
---
45
+
46
+
## Configuration (optional)
47
+
48
+
You can configure defaults globally for your project via a `[tool.envguard]` section in your `pyproject.toml`.
|`exclude`| list of strings |`[".venv", "venv", "env", ".git", "__pycache__", "dist", "build", "node_modules"]`| Directories or file patterns to ignore while scanning your code. |
63
+
|`include`| string or list of strings |`"*.py"`| Glob pattern(s) of files to include when scanning for environment variable usage. |
64
+
|`dotenv`| string |`".env"`| Path to your `.env` file used for validation. |
65
+
|`fail_on`| list of strings |`["missing"]`| Determines which findings trigger a non-zero exit code. Options: `"missing"`, `"typos"`, `"bad_values"`, `"unused"`. |
66
+
67
+
---
68
+
69
+
## Behavior
70
+
71
+
- Ignores common directories like `.venv`, `dist/`, `build/`, and `.git/` by default.
|`exclude`| list of strings |`[".venv", "venv", "env", ".git", "__pycache__", "dist", "build", "node_modules"]`| Directories or file patterns to ignore while scanning your code. |
52
-
|`include`| string or list of strings |`"*.py"`| Glob pattern(s) of files to include when scanning for environment variable usage. |
53
-
|`dotenv`| string |`".env"`| Path to your `.env` file used for validation. |
54
-
|`fail_on`| list of strings |`["missing"]`| Defines which issues should cause a non-zero exit code. Possible values: `"missing"` (variable used in code but not declared), `typos`,`bad_values`, `"unused"` (variable declared but not used). |
101
+
---
55
102
56
-
### Behavior
103
+
##License
57
104
58
-
- By default, `envguard` ignores common virtual environments, build directories, and version control folders.
59
-
- You can override any of these defaults in your `pyproject.toml` to fit your project structure.
60
-
- Command-line arguments override `pyproject.toml` only when explicitly provided.
105
+
**MIT License** – feel free to use, modify, and contribute.
0 commit comments