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