Adding pre-commit
The rationale behind these changes is to catch linter errors (pep8) automatically before developers submit their changes and pull-requests.
These changes will help us become proactive with the apply of our coding rules (pep8, etc...) and avoid back and forth with patches and reviews.
In other words these changes could help us to reduce our CI usages and possibly also help us to reduce the amount (of pending) reviews by catching early issues on the developer side.
Note that pre-commit is optional and people who don't want to use it don't need to do something.
With these changes tox is plugged on pre-commit to run flake8 checks, this approach allow us to centralize things and avoid to duplicate how this kind of test is executed.
Introduced changes:
- pre-commit config and rules
- Flake8 is covered in the pre-commit hooks.
- Applying fixes for pre-commit compliance in all code.
Also it is worth to note that commit hash will be used instead of version tags in pre-commit to prevend arbitrary code from running in developer's machines.
pre-commit will be used to:
- trailing whitespace;
- Replaces or checks mixed line ending (mixed-line-ending);
- Forbid files which have a UTF-8 byte-order marker (check-byte-order-marker);
- Checks that non-binary executables have a proper shebang (check-executables-have-shebangs);
- Check for files that contain merge conflict strings (check-merge-conflict);
- Check for debugger imports and py37+ breakpoint() calls in python source (debug-statements);
- Attempts to load all yaml files to verify syntax (check-yaml);
- Run flake8 checks (flake8) (local)
Also these changes can be used automatically by using:
$ pip install pre-commit
$ pre-commit install
With the previous commands checks will be passed at each commit by using git-hooks' mechanisms.
For further details about tests please refer to: https://github.com/pre-commit/pre-commit-hooks
Also note that the changes on docs/make.bat are simply file permissions to render this file as an executable file.
Thank you.
I'll review this after I finish releasing Celery 5.
@thedrow thanks
Hello @thedrow,
An update about these changes?