Detect unused packages in requirements.txt by scanning imports
Project description
philiprehberger-req-check
Detect unused packages in requirements.txt by scanning imports.
Install
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 |
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
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 philiprehberger_req_check-0.1.2.tar.gz.
File metadata
- Download URL: philiprehberger_req_check-0.1.2.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd23b45b49cdd283870eaae393e02c7ab808649ece8ec9cb7f5442fc86e9c528
|
|
| MD5 |
5fb89b8b8f573127dadaf8e432ea14e7
|
|
| BLAKE2b-256 |
ac6d66926a33798756ff1ec86269da6cf8364b4807edb17636d044191f029a97
|
File details
Details for the file philiprehberger_req_check-0.1.2-py3-none-any.whl.
File metadata
- Download URL: philiprehberger_req_check-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d3c69079a9fc3ab814a522c19542d1afe3089c7d006915ca81caea5a634bb79
|
|
| MD5 |
5db9f5df91fe1990211195aa70f4fe10
|
|
| BLAKE2b-256 |
3e9b7ed48605859886cff6a1a3bc1de5a3ed7d078e7dee36dbb88802802063bd
|