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:
- 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23d1fd8827a20e78f63a85bdf684372bf0ce24a476ba20c2dd886f21500db346
|
|
| MD5 |
b7ffb676262568b7acfc56ddd0cbe999
|
|
| BLAKE2b-256 |
a9dd03ba2cc9d86efeba3aae54019710ffce20c4475d36c509920c67d3d2ac25
|
Provenance
The following attestation bundles were made for pdm_shear-0.1.0.tar.gz:
Publisher:
release.yml on pdm-project/pdm-shear
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdm_shear-0.1.0.tar.gz -
Subject digest:
23d1fd8827a20e78f63a85bdf684372bf0ce24a476ba20c2dd886f21500db346 - Sigstore transparency entry: 192195818
- Sigstore integration time:
-
Permalink:
pdm-project/pdm-shear@5a5b8b472a9cd85e670821ef41444a3e0dddd1fc -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/pdm-project
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5a5b8b472a9cd85e670821ef41444a3e0dddd1fc -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49a09ae5b5d264be6881ccf9347caaf5ad3a54c6673deabebf915bd5c7b083a7
|
|
| MD5 |
a9c42d8ae6a0ff2bb13a6f399898f222
|
|
| BLAKE2b-256 |
7326bcce2ad658fae676d78a69548ddca2af2bb119206ef4c5b27a3554374e43
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdm_shear-0.1.0-py3-none-any.whl -
Subject digest:
49a09ae5b5d264be6881ccf9347caaf5ad3a54c6673deabebf915bd5c7b083a7 - Sigstore transparency entry: 192195819
- Sigstore integration time:
-
Permalink:
pdm-project/pdm-shear@5a5b8b472a9cd85e670821ef41444a3e0dddd1fc -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/pdm-project
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5a5b8b472a9cd85e670821ef41444a3e0dddd1fc -
Trigger Event:
push
-
Statement type: