fpgmaas / deptry

Find unused, missing and transitive dependencies in a Python project.

Home Page:https://deptry.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pre-commit hook requires deptry to be globally installed

kumekay opened this issue · comments

Describe the bug

We run pre-commit for all changes in a merge request in GitLab CI. pre-commit is the only python package-
pre-commit hook requires deptry to be globally installed.

To Reproduce

Steps to reproduce the behavior:

  1. Create .pre-commit-config.yml like:
repos:
  - repo: https://github.com/fpgmaas/deptry.git
    rev: "0.11.0"
    hooks:
      - id: deptry
  1. Install the only package pip install pre-commit
  2. Make some changes in python code and stage changes
  3. Run pre-commit
  4. An error will be returned
[INFO] Initializing environment for https://github.com/fpgmaas/deptry.git.
deptry.................................................................................................Failed
- hook id: deptry
- exit code: 1
Executable `deptry` not found

Expected behavior

Pre-commit installs dependencies by itself.

System [please complete the following information]:

  • OS: e.g. [Debian bullseye]
  • Language Version: [Python 3.10]
  • Poetry version: NA

Additional context

Hi @kumekay, thanks for raising the issue! deptry does not need to be installed globally, but it does need to be installed within the virtual environment of the project. pre-commit creates it's own virtual environment, and thus AFAIK the approach proposed in #415 will not work.

See also the discussion here for more information: #124 (comment)

@fpgmaas Thank you so much for the explanation (and the great tool). Even though this behavior is mentioned in important block in the docs, I was surprised because it's the only pre-commit hook of more than a dozen in our project that requires more than pre-commit package.