The pre-commit hook should only lint staged files
Opened this issue · 0 comments
patrys commented
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:
- Take a clean repository with a deptry hook passing
- Create an untracked Python script with
import foobarbaz
as the only line - Try to commit an unrelated change
- 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