Skip to main content

Detect unused packages in requirements.txt by scanning imports

Project description

philiprehberger-req-check

Tests PyPI version License

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

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.5.tar.gz (6.0 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.5-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_req_check-0.1.5.tar.gz
Algorithm Hash digest
SHA256 8a0121ee2ef77d83925f0c312b4abc498f3310aa76a3307d7a1bc4c2979b8fdd
MD5 6f7bdaefef08f7cb520f06fd54d326c7
BLAKE2b-256 a663edb8d2875ede3277fb6159e380f06d8fc7c41275b70915efe01df4e088b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_req_check-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0061432904463e6c4c3330cd3cebac9f8a2fb0fef7cd819d87f4411f21e369cb
MD5 ab8968ef16c2108c4caaeeb7fd702680
BLAKE2b-256 feecb71f3dacef23e3bce567ddafda1b9143331acda5f46dc50135ed9f77a656

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