generated from tweag/project
-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
Description
Describe the bug
The file-regex in the pre-commit hook matches more than just setup.py. This creates issues when having files like app_setup.py in a repo.
To Reproduce
- Create a clean repo
- touch test_setup.py
- install fawltydeps pre-commit hook
- run prek run --all-files check-unused
Expected behavior
No errors
Environment
- OS Windows 1:
- Version of the code v0.20.0
Additional context
The solution would be to safeguard the files to only match the full name, ie. instead of the existing pattern:
(.*requirements.*\.(txt|in)|pyproject\.toml|setup\.(py|cfg))
do
(^|.+(/|\\))(.*requirements.*\.(txt|in)|pyproject\.toml|setup\.(py|cfg))
which will require the files to be on root (^) or a subdirectory (adjusted for linux & windows fileseps)
This would successfully match
setup.py
sub/dir/setup.py
sub\dir\setup.py
setup.cfg
sub/dir/setup.cfg
sub\dir\setup.cfg
pyproject.toml
sub/dir/pyproject.toml
sub\dir\pyproject.toml
requirements.txt
sub/dir/requirements.txt
sub\dir\requirements.txt
dev_requirements.txt
sub/dir/dev_requirements.txt
sub\dir\dev_requirements.txt
requirements_prod.txt
sub/dir/requirements_prod.txt
sub\dir\requirements_prod.txt
requirements.in
sub/dir/requirements.in
sub\dir\requirements.in
dev_requirements.in
sub/dir/dev_requirements.in
sub\dir\dev_requirements.in
requirements_prod.in
sub/dir/requirements_prod.in
sub\dir\requirements_prod.in
But would not match
test_setup.py
sub\dir\test_setup.py
sub/dir/test_setup.py
testsetup.py
sub\dir\testsetup.py
sub/dir/testsetup.py
setup_test.py
sub\dir\setup_test.py
sub/dir/setup_test.py
setuptest.py
sub\dir\setuptest.py
sub/dir/setuptest.py
spyproject.toml
sub/dir/spyproject.toml
sub\dir\spyproject.toml
pyprojects.toml
sub/dir/spyprojects.toml
sub\dir\pyprojects.toml
zz1874jherland