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
added github action to auto pep8 #1435
base: develop
Are you sure you want to change the base?
Conversation
Thanks @shimwell - this looks like a good addition, but probably something that will introduce a lot of changes upon merging. A few thoughts:
|
Thanks @gonuke and double thanks for all the packaging work I noticed elsewhere. 1 rename 👍 |
This looks good to me, but let me wait on #1436 before moving forward. I do have a best practice/workflow question - this change means that a local copy of a git branch becomes out of sync with a remote copy upon pushing that copy. This makes me uneasy since a typical workflow will be:
At each push there is the potential of things becoming misaligned.... I am sure others use autoformatting workflows like this, so I am interested in learning the best practice. |
Pre-commit formatting is a popular choice for devs. It does the formatting locally before the commit. |
I can add a repos:
- repo: https://github.com/psf/black
rev: 22.1.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-toml
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace More info on pre-commit here |
Do I understand correctly that forcing pre-commit will require everyone to make sure they've installed some |
Developers can optionally install pre-commit with pip install pre-commit. If they do then formatting will be applied prior to a git commit. Pep8 formatting will be done locally and pushed commits will be cleaner. If contributors don't have pre-commit installed or don't want to install it then that is not a problem and they can make a PR in the normal way. Pep8 formatting will be done by then Github Action and the commit history will have a few more commits as it will potentially have some ``[skip ci] formatting commit``` made by the action. Then the contributor may have to pull to before pushing their next commit to an open PR. Installing pre-commit is optional, the existence of a Happy to give a demo at the next catch up |
Description
This PR adds a github action that automatically formats the python code using black.
Motivation and Context
It saves developers time and effort as there would no longer be a need make commits for pep8 changes
It saves review time as the reviewer doesn't have to check the pep8 formatting
Changes
What kind of change does this PR introduce? (Bug fix, feature, documentation update...)
Automation
Behavior
What is the current behavior? What is the new behavior?
current behavior - PR is made with pep errors -> reviewer make comments in the review requesting pep8 changes -> PR contributor makes changes -> reviewer checks they are correct and accepts changes
new behavior - PR is made with pep error -> pep8 formatting is automatically corrected and committed to the PR
Other Information
Other relevant information to this pull request.
The CI is not rerun for these pep8 commits
Changelog file
All pull requests are required to update the CHANGELOG file with the PR. Your update can take different forms including: