A CLI tool to scan Python projects for dependencies and unused imports.
Project description
ImportNinja
ImportNinja is a Python CLI tool designed to scan your projects for dependencies, detect unused imports, and help keep your requirements.txt file clean and up-to-date. Simplify your dependency management with lightning-fast scans and detailed reports.
Features
- Recursive Scanning: Scans all
.pyfiles in your project. - Detects Unused Imports: Identifies libraries that are imported but never used.
- Requirements Analysis: Checks if your
requirements.txtis up to date. - Automatic Updates: Optionally writes missing dependencies to
requirements.txt. - Fast & Lightweight: Built using Python's
astfor efficient parsing.
Installation
Install ImportNinja directly from PyPI:
pip install ImportNinja
Usage
Basic Command
import-ninja /path/to/your/project
This will scan the project directory and list all detected dependencies and unused imports.
With Requirements File
import-ninja /path/to/your/project -r requirements.txt
-ror--requirements: Specify therequirements.txtfile to compare with detected imports. ImportNinja will analyze and suggest updates.
Example Output
Scanning for imports...
Total Python Files Scanned: 6
Total Import Statements: 9
Unique Libraries Imported: 8
Total Unused Imports: 6
Unused Imports:
- setup.py:
- setuptools
- ImportNinja\analyzer.py:
- pathlib
- ImportNinja\cli.py:
- ImportNinja.scanner
- ImportNinja.utils
- ImportNinja.analyzer
- ImportNinja\scanner.py:
- pathlib
Requirements file analysis:
Imports missing in requirements.txt:
- sys
- ast
- argparse
- pathlib
Dependencies:
- argparse
- ast
- pathlib
- setuptools
- sys
Requirements saved to requirements.txt
Contributing
We welcome contributions! To get started:
- Fork the repository.
- Create a new branch:
git checkout -b feature/your-feature-name. - Make your changes.
- Run tests to ensure everything works.
- Submit a pull request!
License
This project is licensed under the MIT License.
Links
Contact
For questions or support, feel free to reach out:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file importninja-0.1.2.tar.gz.
File metadata
- Download URL: importninja-0.1.2.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64b9af7b8137116a7a9f543a4f1d904dc3c5302c1b7669c1740e2ee0076accf1
|
|
| MD5 |
db3201ef42cdfb6028f8d056ccc0c6f9
|
|
| BLAKE2b-256 |
437be03b0b7d1f6b6315cc090f63033c4b0be8327b85f0c7262bdbfc131fa27a
|
File details
Details for the file ImportNinja-0.1.2-py3-none-any.whl.
File metadata
- Download URL: ImportNinja-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
727f0248e05453276f0e0c4f6a333a3b51d29384b70365982380771bba91f5cb
|
|
| MD5 |
2f78887f056bbd7840fb13cb6447bcc8
|
|
| BLAKE2b-256 |
cf81c536aff72836af2ec6788c4bf18387e670dfa9301fa65ddfc79c2a6138d8
|