-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
pre-commit-hooks.yaml #5157
pre-commit-hooks.yaml #5157
Conversation
Thanks for the PR, but we have |
Oh, this might be about something else? https://github.com/pre-commit/pre-commit-hooks |
Codecov Report
@@ Coverage Diff @@
## master #5157 +/- ##
==========================================
+ Coverage 95.79% 96.06% +0.27%
==========================================
Files 114 114
Lines 25825 25825
Branches 2550 2550
==========================================
+ Hits 24740 24810 +70
+ Misses 757 705 -52
+ Partials 328 310 -18
Continue to review full report at Codecov.
|
👋 first thanks for the contribution! I think there's a few reasons this won't work for the general case and often is better suited for a First and foremost is the technical limitation. since pre-commit creates isolated environments for each hook, they (usually) won't have access to your project and its dependencies (meaning this config would only really work out-of-the-box for a project which had no dependencies, no test dependencies, and was using a non-src layout). Granted a consumer can ~kinda fix that by twiddling The second, and perhaps the more important (?) is the ergonomics of such a hook. While I (and others) have been working a bit on improving pytest startup / runtime, it's still a pretty slow task to execute a full test suite. Even if startup time were near zero, running a full test suite on every commit in the critical path adds up quickly (and will likely be the slowest part of that commit) -- if I find a hook is slower than others I tend to disable it, and others will outright disable the whole tool! That said, there still are situations where I've reached for pytest as a hook in pre-commit, though it wasn't necessarily pretty to make it happen: |
Ah, now I see what it is about.. :) Might make sense with something like pytest-testmon (https://github.com/tarpas/pytest-testmon), diff-cover (https://github.com/Bachmann1234/diff-cover) or something similar only really. But even if it only takes a few seconds I would still prefer to not have it on by default. |
@asottile, @blueyed Thanks for having considered my pr! Best |
i believe there is still some structural merit to those, but i cant quite put it into the right words yet when pytest no longer uses pkg_resources, it may be sensible to run a core set of unit-tests on commit for example to prevent blunters - there is various small projects where this is entirely sensible |
Thanks @MathersMax for the contribution and understanding, and everyone else for the excellent discussion. 👍 |
Hi :)
Sorry I'm not compliant with your contributing guidelines but this pr is not about the project itself, it's about being able to use it automatically with
pre-commit
.I was looking for a way to run my tests before every commit and was surprised to discover that you use
pre-commit
for your own development workflow but do not provide apre-commit-hooks.yaml
So here's one, I'm using it from my fork and it does the job.
I hope you'll accept this little change.
Regards