简介
deptry 是一个命令行工具,用于检查 Python 项目中依赖项的问题,例如未使用或缺失的依赖项。它支持使用 Poetry 、 pip 、 PDM 、 uv 的项目,以及任何支持 PEP 621 规范的项目。
安装 Deptry
你可以通过 poetry 轻松安装 Deptry:
poetry add deptry
基本用法
在项目根目录下运行以下命令即可开始分析:
deptry .
输出
Scanning 6 files...
download.py:1:8: DEP003 'requests' imported but it is a transitive dependency
main.py:10:1: DEP003 'starlette' imported but it is a transitive dependency
pyproject.toml: DEP002 'deptry' defined as a dependency but not used in the codebase
pyproject.toml: DEP002 'jinja2' defined as a dependency but not used in the codebase
utils.py:7:8: DEP003 'redis' imported but it is a transitive dependency
Found 5 dependency issues.
For more information, see the documentation: https://deptry.com/
欢迎关注我的博客www.bboy.app
Have Fun