deptry is a command line tool to check for issues with dependencies in a poetry managed Python project. It checks for three types of issues:
- Obsolete dependencies: Dependencies which are added to your project's dependencies, but which are not used within the codebase.
- Transitive dependencies: Packages from which code is imported, but the package (A) itself is not in your projects dependencies. Instead, another package (B) is in your list of dependencies, which depends on (A). Package (A) should be added to your project's list of dependencies.
- Missing dependencies: Modules that are imported within your project, but no corresponding package is found in the environment.
deptry detects these issue by scanning the imported modules within all Python files in a directory and it's subdirectories, and comparing those to the dependencies listed in pyproject.toml.
Documentation: https://fpgmaas.github.io/deptry/
deptry can be added to your project with
poetry add --group dev deptry
or for older versions of poetry:
poetry add --dev deptry
In order to check for obsolete imports, deptry requires a pyproject.toml file to be present in the directory passed as the first argument, and it requires the corresponding environment to be activated.
To scan your project for obsolete imports, run
deptry .deptry can be configured by using additional command line arguments, or
by adding a [tool.deptry] section in pyproject.toml.
For more information, see the documentation.
Repository initiated with fpgmaas/cookiecutter-poetry.