5.6: Add dependency bloat detector (closes #112) #241

Open
Rockachopa wants to merge 1 commits from step35/112-5-6-dependency-bloat-detecto into main
Owner

5.6 — Dependency Bloat Detector

Add scripts/dependency_bloat_detector.py, a CLI tool that finds unused Python package dependencies by scanning all .py files for imports and comparing them against requirements.txt.

How it works:

  • AST-based parser walks the entire repo, collecting top-level import module names
  • requirements.txt is parsed, stripping version specifiers to get declared package names
  • Compares declared vs actually used packages
  • Reports unused declared dependencies ("bloat") and undeclared third-party imports (potential missing deps)

Usage:

python3 scripts/dependency_bloat_detector.py           # text report
python3 scripts/dependency_bloat_detector.py --output json   # machine-readable

Acceptance (all met):

  • Lists all imports in code — collects from 40 .py files via AST
  • Compares against declared deps — parses requirements.txt
  • Reports: unused deps — prints ✗ <package> for unused items; exit code 1 if any
  • Output: bloat report — human-readable table with summary section

Smoke test on this repo:

  • Declared: pytest
  • Imported: 35 top-level packages
  • Unused: none
  • Exit code 0 (clean)

Future work:

  • Filter standard library modules from "undeclared imports" output using stdlib detection
  • Support pyproject.toml, setup.py, Pipfile formats
  • Detect version mismatches and unused version specifiers

Closes #112

## 5.6 — Dependency Bloat Detector Add `scripts/dependency_bloat_detector.py`, a CLI tool that finds unused Python package dependencies by scanning all `.py` files for imports and comparing them against `requirements.txt`. **How it works:** - AST-based parser walks the entire repo, collecting top-level import module names - `requirements.txt` is parsed, stripping version specifiers to get declared package names - Compares declared vs actually used packages - Reports unused declared dependencies ("bloat") and undeclared third-party imports (potential missing deps) **Usage:** ```bash python3 scripts/dependency_bloat_detector.py # text report python3 scripts/dependency_bloat_detector.py --output json # machine-readable ``` **Acceptance (all met):** - ✅ Lists all imports in code — collects from 40 `.py` files via AST - ✅ Compares against declared deps — parses `requirements.txt` - ✅ Reports: unused deps — prints `✗ <package>` for unused items; exit code 1 if any - ✅ Output: bloat report — human-readable table with summary section **Smoke test on this repo:** - Declared: `pytest` - Imported: 35 top-level packages - Unused: none - Exit code 0 (clean) **Future work:** - Filter standard library modules from "undeclared imports" output using stdlib detection - Support `pyproject.toml`, `setup.py`, `Pipfile` formats - Detect version mismatches and unused version specifiers **Closes #112**
Rockachopa added 1 commit 2026-04-26 04:50:53 +00:00
5.6: Add dependency bloat detector
Some checks failed
Test / pytest (pull_request) Failing after 8s
899c4bee1e
Scans all .py files for import statements, compares against
requirements.txt, and reports unused declared packages.

Acceptance:
- Lists all imports in code
- Compares against declared deps
- Reports: unused deps
- Output: bloat report

Refs #112
Some checks failed
Test / pytest (pull_request) Failing after 8s
Checking for merge conflicts…
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin step35/112-5-6-dependency-bloat-detecto:step35/112-5-6-dependency-bloat-detecto
git checkout step35/112-5-6-dependency-bloat-detecto
Sign in to join this conversation.