Skip to main content

Detect unused packages in requirements.txt by scanning imports

Project description

philiprehberger-req-check

Tests PyPI version Last updated

Detect unused packages in requirements.txt by scanning imports.

Installation

pip install philiprehberger-req-check

Usage

from philiprehberger_req_check import check

# Find unused packages in a project directory
unused = check("./my-project")
print(unused)  # ["some-unused-package"]

Scan Imports

from philiprehberger_req_check import scan_imports

imports = scan_imports("./my-project")
print(imports)  # {"requests", "flask", "os", "sys", ...}

Read Requirements

from philiprehberger_req_check import read_requirements

packages = read_requirements("requirements.txt")
print(packages)  # ["requests", "flask", "pillow"]

CLI

python -m philiprehberger_req_check ./my-project

Exits with code 1 if unused packages are found.

API

Function Description
check(path, *, requirements=None) Find unused packages by comparing imports against requirements
scan_imports(path) Scan Python files for top-level import names
read_requirements(path) Read package names from requirements.txt

Development

pip install -e .
python -m pytest tests/ -v

Support

If you find this project useful:

Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

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

philiprehberger_req_check-0.1.6.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

philiprehberger_req_check-0.1.6-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_req_check-0.1.6.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_req_check-0.1.6.tar.gz
Algorithm Hash digest
SHA256 e99ea60a828ce1bf2b3f8923fc8c2aa0615220c585e592f87f736d8783142fd0
MD5 422622f44eef79e2c693c93075d82a24
BLAKE2b-256 160d214248368304bcab92f2a6fbce89379d8d18fcda0cc49c08caf0d1ea0755

See more details on using hashes here.

File details

Details for the file philiprehberger_req_check-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_req_check-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4e255d9289d4bcc2b88c85d01c18025f9215f3e2a16c41fb1f24742601147f62
MD5 5c58e36a8127e6af972a3349c5be2d9b
BLAKE2b-256 e08c999529ac4cd6d833da2431433d6ac8d2818b45f3971c966441a98b0ddd69

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