philiprehberger-req-check
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"]
Finding missing dependencies
from philiprehberger_req_check import find_missing
# Imports used in code but NOT declared in requirements.txt
missing = find_missing("requirements.txt", "./src")
print(missing) # {"yaml"}
Comparing requirements
from philiprehberger_req_check import compare
diff = compare("requirements.old.txt", "requirements.new.txt")
print(diff)
# {"added": ["httpx"], "removed": ["yaml"], "common": ["requests"]}
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 |
find_missing(requirements_path, source_dir) |
Find imports used in source but not declared in requirements |
compare(req_a, req_b) |
Diff two requirements files into added / removed / common |
Development
pip install -e .
python -m pytest tests/ -v
Support
If you find this project useful:
License
Metadata
Release files for philiprehberger-req-check 0.2.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 | Provenance | Actions |
|---|---|---|---|---|
| philiprehberger_req_check-0.2.0.tar.gz | 186.0 kB | Without provenance | Details for philiprehberger_req_check-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| philiprehberger_req_check-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for philiprehberger_req_check-0.2.0-py3-none-any.whl |
Total release size: 192.9 kB
Release files / philiprehberger_req_check-0.2.0.tar.gz
| Download URL | philiprehberger_req_check-0.2.0.tar.gz |
|---|---|
| Size | 186.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
27c1fdf3c5ce594da0140a59a6492db238b6d94eac486ff43b14eed17801dc7a
|
|
BLAKE2b-256 checksum How to use checksums |
cbd317d64d582dacad14e531de16ac0a3b8137b1dfb9109adb9d30f63700caa2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / philiprehberger_req_check-0.2.0-py3-none-any.whl
| Download URL | philiprehberger_req_check-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8780ded553292106d91c0cba4ff020704cdc746e9249e3e22e9c8fe2f42e15d5
|
|
BLAKE2b-256 checksum How to use checksums |
8127ca2cac9e8fa4bb161d65d761edac61e7a31bfc85df2d2570a437c88b5706
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Security for philiprehberger-req-check 0.2.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.