-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add a pre-commit hook config file #244
add a pre-commit hook config file #244
Conversation
Thanks! The code looks good, I modified it slightly though. However, I'm not sure how useful the pre-commit integration will be, because it will test modified files and maybe even only one file at a time. Can you test this and confirm these two things, please? Is there a way to always check all Python files tracked by the Git repo? Also, can you check that the pre-commit invocation really uses the Vulture configuration from the pyproject.toml file? |
I confirm that it checks only modified files (unless run with --all-files flag as in my screenshot above, which is also what pre-commit-ci does underneath), but it catches them all: not just one by one.
I'm pretty sure there is, but I need to inquire this further. I'll get back at you !
Yup. Tested on a large (and old) repo, and I confirm that my configuration is correctly used. This is what I used:
(both screen shots are cut off, you get the point) |
So I haven't worked my head around it yet but as a note the hook for https://github.com/asottile/dead does it (asottile is also the author of pre-commit), so it's definitely possible ! Writing this I am also realising I may have misinterpreted your question about testing files one by one... of course you meant to check wether vulture is still able to connect the dots if something is unused in the file where it's defined but imported elsewhere. I think that indeed it only looks at the subset of modified files so one gets pretty garbage reports in that state (which I didn't realise because everything looks good when the min confidence is set to 100%). |
Here is the mechanism Anthony used to systematically run dead against all files: Replicating this feature in vulture would obviously require a deeper patch. |
I'm only a vulture user migrating to pre-commit, but that's one honking great idea! |
I think another option is to use |
…d pass_files: false so that vulture can detect files itself
I don't know how one would do this. Maybe I'm just confused. Could you elaborate ? The rest ( |
I mean that we should add something along the following lines to the README: To run Vulture before each commit, add the following pre-commit hook to |
Codecov Report
@@ Coverage Diff @@
## master #244 +/- ##
=======================================
Coverage 99.36% 99.36%
=======================================
Files 17 17
Lines 631 631
=======================================
Hits 627 627
Misses 4 4 Continue to review full report at Codecov.
|
Thanks (and done) ! I can also confirm after testing this setup locally that it works like a charm ! |
Thanks! |
Thank you for merging ! can you please bump Vulture's version to 2.3 ? |
Done :-) |
Description
Adding this file to the repo makes vulture usable as a hook for pre-commit.
As such, it can be easily integrated to a shared development workflow and to CI (in particular within pre-commit.ci)
Related Issue
none
Checklist: