-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add black as an auto formatter #3694
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
Conversation
4ae0755
to
7bec5fb
Compare
Fixed conflicts and rebased off master. Since there seems to be some crickets on this PR, so I'll make a few comments. This is an incredibly large PR, and likely impossible to review every change. Merging this basically surrenders our formatting to an external program. While every change may not always be perfect, I believe that overall it will be a net positive as it will increase readability in most cases and also completely removes any formatting frustrations for both reviewers and contributors. As a side note, the current testing errors are due to #3708. We can be sure black doesn't change any actual code meaning as it creates an AST before and after formatting. |
I believe the current plan for v1.5.0 is to be the last release that supports python 2.7, 3.4 and 3.5. But, until then, we still have to deal with issues for those python versions. |
This reverts commit f48ff57. Decided to leave fixing the linting errors until extra tests etc. have been integrated, or beetbox#3694 is merged.
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Description
See discussion
tox -e lint
now runspre-commit run -a
(see below)To add this to your workflow, I recommend creating a git hook with pre-commit. Note that this is optional and you can just run the checks as normal with
tox -e lint
if you don't want the hooks in your git workflow. Another option, if you don't want to run the hooks for some reason on any particular commit, you can usegit commit -n [--no-verify]
To install the hook run
pre-commit install
. This will now enforce black and flake8 prior to completing the commit. It will only check files that were commited, so the performance hit isn't an issue.Example workflow for a compliant commit:
Example for a commit that is not compliant with the lint checks:
$ git commit black....................................................................Failed - hook id: black - files were modified by this hook reformatted setup.py All done! ✨ 🍰 ✨ 1 file reformatted. flake8...................................................................Passed
Note that since it was a formatting issue, black will automatically apply the chang 8000 es. However, you will need to re-stage and attempt the commit again. These checks will occur prior to writing the commit message if you don't use
git commit -m
.To run the linting commands normally on all files (does not require the
pre-commit install
command) runpre-commit run -a
. This is now exactly whattox -e lint
will do.Edit: this would also significantly affect #3673 as a lot of those changes would no longer be required.
To Do