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.1.tar.gz (7.5 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.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: importninja-0.1.1.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

Hashes for importninja-0.1.1.tar.gz
Algorithm Hash digest
SHA256 584594d15de76545fb83c187e69ab4e39efb993eba4a48fe8b717c287908cf91
MD5 1848080bf0d22e6684ad3d289c48a491
BLAKE2b-256 bb17941c1495c99020c1dc090c31bcff55b3fb25ce502422d252186ee1e416f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ImportNinja-0.1.1-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

Hashes for ImportNinja-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7604b62988049f5e756f1edd929cc7006774c8d8ab9e789611b3fd3cd741e275
MD5 139d3367ad67a335d20e7456f4caee9d
BLAKE2b-256 e685e4b65ae89d554d1e6128873b70952a03f336b250e9de285e75add08f7ffa

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