deptry icon indicating copy to clipboard operation
deptry copied to clipboard

The pre-commit hook should only lint staged files

Open patrys opened this issue 2 years ago • 3 comments

Describe the bug

When the repository contains files that are not going to be committed (for example, not tracked by git at all), the pre-commit hook for deptry will fail if any of those files don't pass the checks. This is inconsistent with the behavior of other pre-commit hooks, which only validate the changes that are about to be committed.

To Reproduce

Steps to reproduce the behavior:

  1. Take a clean repository with a deptry hook passing
  2. Create an untracked Python script with import foobarbaz as the only line
  3. Try to commit an unrelated change
  4. See the hook fail, complaining about an unlisted dependency on foobarbaz

Expected behavior

The hook should ignore any files that are not going to be part of the commit.

System [please complete the following information]:

  • OS: macOS Sonoma 14.0
  • Language Version: Python 3.9
  • Poetry version: 1.7.0

Additional context

N/A

patrys avatar Nov 15 '23 11:11 patrys

Would love to see movement on this. It makes deptry a huge annoyance in pre-commit without it.

mjspeck avatar Jan 24 '25 17:01 mjspeck

Would love to see movement on this. It makes deptry a huge annoyance in pre-commit without it.

100% agree

fontclos avatar May 20 '25 08:05 fontclos

We are now also hitting this issue. It would be great if this could be fixed!

gwdekker avatar Oct 15 '25 18:10 gwdekker