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:
- Find all import statements and their locations
- Compare them against your declared dependencies
- Identify dependencies that aren't used in your code
- Optionally detect imports that don't map to any dependency
License
MIT
Metadata
Release files for pdm-shear 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pdm_shear-0.1.0.tar.gz | 6.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pdm_shear-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.4 kB
Release files / pdm_shear-0.1.0.tar.gz
| Download URL | pdm_shear-0.1.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
23d1fd8827a20e78f63a85bdf684372bf0ce24a476ba20c2dd886f21500db346
|
|
BLAKE2b-256 checksum How to use checksums |
a9dd03ba2cc9d86efeba3aae54019710ffce20c4475d36c509920c67d3d2ac25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2025.
Transparency logRelease files / pdm_shear-0.1.0-py3-none-any.whl
| Download URL | pdm_shear-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
49a09ae5b5d264be6881ccf9347caaf5ad3a54c6673deabebf915bd5c7b083a7
|
|
BLAKE2b-256 checksum How to use checksums |
7326bcce2ad658fae676d78a69548ddca2af2bb119206ef4c5b27a3554374e43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2025.
Transparency log