Skip to main content

dep-prune

A tool to analyze your Python project's dependencies and identify unused imports.

  1. Reads pyproject.toml - Supports multiple formats:

    • Poetry (tool.poetry.dependencies)
    • PEP 621 standard (project.dependencies)
    • PDM format
    • Handles dev dependencies and optional/group dependencies
  2. Scans all Python files - Recursively finds all .py files in your project

    • Automatically excludes common directories (.git, __pycache__, venv, etc.)
    • Uses AST parsing for accurate import detection
  3. Extracts imports - Finds all:

    • Regular imports: import package
    • From imports: from package import something
    • Handles nested modules correctly

Usage:

# Basic usage (analyze current directory)
uvx dep-prune

# Analyze specific directory
uvx dep-prune /path/to/project

# Specify custom pyproject.toml location
uvx dep-prune --pyproject /custom/path/pyproject.toml

# Verbose mode for detailed output
uvx dep-prune -v

Installation:

You'll need to install the toml package to run this tool:

pip install toml

Example Output:

Analyzing project at: /path/to/project
Reading pyproject.toml from: /path/to/project/pyproject.toml

Found dependency groups:
  main: 15 packages
  dev: 8 packages

Found 127 Python files

============================================================
Analyzing main dependencies:
============================================================

✓ Used packages (12):
  • flask
  • numpy
  • pandas
  • requests

⚠ Potentially unused packages (3):
  • some-unused-lib
  • another-unused-package
  • legacy-dependency

Summary for main:
  Total: 15
  Used: 12
  Potentially unused: 3

Metadata

Release files for dep-prune 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dep-prune 0.2.0
File Size Uploaded
dep_prune-0.2.0.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dep-prune 0.2.0
File Interpreter ABI Platform
dep_prune-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.6 kB

Release files / dep_prune-0.2.0.tar.gz

Download URL dep_prune-0.2.0.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
302cde18af769ffb32cc7ca988edc69b072a5d9596fcc90332462017c79912b0
BLAKE2b-256 checksum
How to use checksums
960ea80aa0260d95dc10319924ba60a22e484f6cff1fc757c3e7b14543de6c15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.0

Release files / dep_prune-0.2.0-py3-none-any.whl

Download URL dep_prune-0.2.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad3c0aa50e88fc4605c581eeabd02f6d998ad6451f7d262460898de626809714
BLAKE2b-256 checksum
How to use checksums
5fbccbcec8adcd77a71773f2de2175f51fda35a91d99012507cfcc4fa36ac80f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.0

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page