Add pre commit config#19
Add pre commit config#19dosisod merged 2 commits intodosisod:masterfrom EFord36:add-pre-commit-config
Conversation
Allows refurb to be installed as a pre-commit hook for users.
This seems to cause the 'explain' message at the bottom to be output inconsistently.
dosisod
left a comment
There was a problem hiding this comment.
Thank you for the work and testing you put into making this PR! I think this is a good addition, since it seems a lot more people will use Refurb if this is added.
In regards to the requires_serial issue, it will be best to keep it set to true. In my testing, it takes (slightly) longer to run in parallel, while only using up more CPU time. See this issue which shows a nice example. Since Mypy is the underlying type checker, we are at it's mercy when it comes to performance and caching. Running in serial also has the added benefit of making the "Use --explain ..." errors from appearing out of order.
Again, thank you for the PR, and thank you for using Refurb!
|
And yes, submitting a PR to the pre-commit hook page is fine by me |
Addresses #10
Sets up a pre-commit hook in the repo so that users can use the repo to set up refurb as a pre-commit hook in their projects.
my
.pre-commit-config.yamlfile contents while testing (I also used the pre-commit try-repo command while I was working this out:If this was merged into the base repo, it would just be:
I've tested this on single files with one issue, multiple issues, multiple files (one with multiple issues), multiple clean files,
pre-commit run -a refurbto test it works running over a codebase of existing files (admittedly a small one) - in the cases of all 'clean', some with problems. All work fine for me on a test repo.One tricky caveat I noticed -
require_serial: trueseems to be a good idea, otherwise the built-in pre-commit multiprocessing means the 'Runrefurb --explain ERRto further explain an error. Use--quietto silence this message' get output multiple times in unpredictable ways when handling multiple files:Another way to address this would be to remove the
require_serial: trueoption and add anargsoption to the file so that--quietis passed - I didn't want to do this by default without discussing with you though. Happy to change if that's what you prefer (it might be more performant - a quick scan of refurb'smain.pylooks like it just loops over files rather than having multiprocessing?).If you did accept this PR, I could also ask if it's possible to add refurb into the set of supported hooks in pre-commit.com by forking the repo for that site and adding your repo in if you were interested?
Final point - thanks for refurb - it looks really interesting and as someone who loves doing code reviews as well I appreciate the effort :)