Hi All

I have opened a ticket[1]  which proposes to add pre-commit[2] to Django, 
and wish to gather thoughts on it here. 

For anyone not familiar pre-commit checks for simple issues before each 
`git commit`. The aim is to try and catch format errors closer to the 
developer and therefore reduce C/I tests that need to be re-run. 

I propose that we add pre-commit hooks for the existing code style checks 
(flake8, isort) and to check for the whitespace rule. In addition, we can 
add a hook for an empty last line. My thought on an initial setup is 
something like this[3].

Documentation would be added as part of the guide to getting set up with 
the Django test suite [4] and would include notes on how to install the 
pre-commit hooks. I also think a smaller note with the patch review 
checklist could also be useful.

Looking ahead I think this tool would be very useful to have in place for 
when Black (DEP8) is added as it will be much more strict on code style. 
This will result
in far more pull requests being opened and commits being pushed which will 
fail the code style checks quickly. If we can reduce the number of times 
this happens
then I think this is a good change. 

Final note is that while thinking about how to flag this to users I 
wondered if a pull request template would be helpful, with the checklist in 
it, and a notice about pre-commit? 

Kind Regards

David

[1] - https://code.djangoproject.com/ticket/32165
[2] - https://pre-commit.com/
[3] - https://gist.github.com/smithdc1/66e6f696beec25e47fdbbef4bca4ab34
[4] - 
https://docs.djangoproject.com/en/3.1/intro/contributing/#previewing-your-changes

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/c114c95a-e9a4-4b25-8a6b-54ae4bac9b22n%40googlegroups.com.

Reply via email to