Skip to main content

Detect and remove unused dependencies for Python projects

Project description

pdm-shear

Detect and remove unused dependencies for Python projects

Installation

Enable the plugin:

pdm self add pdm-shear

Enable the plugin in your project:

[tool.pdm]
plugins = ["pdm-shear"]

And run the following command once in your project:

pdm install --plugins

Usage

Run the shear command to analyze dependencies:

pdm shear

This will show you a report of:

  • Unused direct dependencies
  • Unused optional dependencies
  • Missing dependencies (if enabled)

Options

  • --fix: Remove the unused dependencies from pyproject.toml automatically
  • --ignore-missing-deps: Don't report missing dependencies

Configuration

In pyproject.toml, you can configure the plugin behavior:

[tool.pdm.shear]
# Paths to include in the analysis (glob patterns)
include = ["src/*.py", "tests/*.py"]
# Paths to exclude from the analysis (glob patterns)
exclude = ["tests/fixtures/*.py"]
# Don't show missing dependencies warnings
ignore_missing_deps = true

How It Works

pdm-shear analyzes your Python source code to:

  1. Find all import statements and their locations
  2. Compare them against your declared dependencies
  3. Identify dependencies that aren't used in your code
  4. Optionally detect imports that don't map to any dependency

License

MIT

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

pdm_shear-0.1.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

pdm_shear-0.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pdm_shear-0.1.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pdm_shear-0.1.0.tar.gz
Algorithm Hash digest
SHA256 23d1fd8827a20e78f63a85bdf684372bf0ce24a476ba20c2dd886f21500db346
MD5 b7ffb676262568b7acfc56ddd0cbe999
BLAKE2b-256 a9dd03ba2cc9d86efeba3aae54019710ffce20c4475d36c509920c67d3d2ac25

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdm_shear-0.1.0.tar.gz:

Publisher: release.yml on pdm-project/pdm-shear

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: pdm_shear-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pdm_shear-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 49a09ae5b5d264be6881ccf9347caaf5ad3a54c6673deabebf915bd5c7b083a7
MD5 a9c42d8ae6a0ff2bb13a6f399898f222
BLAKE2b-256 7326bcce2ad658fae676d78a69548ddca2af2bb119206ef4c5b27a3554374e43

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdm_shear-0.1.0-py3-none-any.whl:

Publisher: release.yml on pdm-project/pdm-shear

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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