fpgmaas/deptry

The pre-commit hook should only lint staged files

Opened this issue · 0 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