import-scanner
import-scanner is a lightweight command-line tool that analyzes Python projects to detect unused imports and generates a clean patch file showing exactly which lines can be removed. It helps maintain clean, readable, and efficient code by identifying imports that are declared but never used in the module.
Features
Scans all .py files in a given directory (recursively)
Uses Python's built-in ast module to parse code safely
Detects unused import and from ... import ... statements
Outputs a standard unified diff (patch) format for review or application
Safe: does not modify files directly; lets you review changes first
No external dependencies — built entirely on Python standard library
Usage
Run the tool from the command line by specifying the target directory:
python main.py /path/to/python/project
Enter fullscreen mode
Exit fullscreen mode
The tool will print a patch to stdout. You can save it to a file or pipe it:
python main.py .…