Skip to main content

A CLI tool to scan Python projects for dependencies and unused imports.

Project description

ImportNinja

Build Status PyPI version License

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 .py files in your project.
  • Detects Unused Imports: Identifies libraries that are imported but never used.
  • Requirements Analysis: Checks if your requirements.txt is up to date.
  • Automatic Updates: Optionally writes missing dependencies to requirements.txt.
  • Fast & Lightweight: Built using Python's ast for 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
  • -r or --requirements: Specify the requirements.txt file 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:

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature/your-feature-name.
  3. Make your changes.
  4. Run tests to ensure everything works.
  5. Submit a pull request!

License

This project is licensed under the MIT License.


Links


Contact

For questions or support, feel free to reach out:

GitHub

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

importninja-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ImportNinja-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file importninja-0.1.0.tar.gz.

File metadata

  • Download URL: importninja-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.0 CPython/3.10.8

File hashes

Hashes for importninja-0.1.0.tar.gz
Algorithm Hash digest
SHA256 37ae959f3cf24064c8d6a70890283bea8460e537e5aa4d9b1ca08c518ea76442
MD5 e3f49de3a42205e869e4a550a09b08b5
BLAKE2b-256 0a6eb131e06f0280b99180c53aaa3a6fb78409ca3b5849237ce3fbb1a8a65477

See more details on using hashes here.

File details

Details for the file ImportNinja-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ImportNinja-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.0 CPython/3.10.8

File hashes

Hashes for ImportNinja-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 88145d6de52d24cbc47c9c48bd987929b055a8e0b865e7d898caa4d104c9fab3
MD5 b3f814588b6fd1de456d5e389892d5e9
BLAKE2b-256 fd78cf8d24c6b24ce153fd384df0a841a89535a06d82b2f40bd68f087c7c90b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page