-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Format and check all Python code using python black #1776
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wohali
force-pushed
the
python-black
branch
4 times, most recently
from
November 29, 2018 06:33
160c2ca
to
be6c902
Compare
jaydoane
reviewed
Nov 29, 2018
davisp
reviewed
Dec 6, 2018
davisp
approved these changes
Dec 6, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 Yay consistency!
The Makefile target builds a python3 venv at .venv and installs black if possible. Since black is Python 3.6 and up only, we skip the check on systems with an older Python 3.x.
janl
pushed a commit
that referenced
this pull request
Feb 7, 2019
The Makefile target builds a python3 venv at .venv and installs black if possible. Since black is Python 3.6 and up only, we skip the check on systems with an older Python 3.x.
janl
pushed a commit
that referenced
this pull request
Feb 17, 2019
The Makefile target builds a python3 venv at .venv and installs black if possible. Since black is Python 3.6 and up only, we skip the check on systems with an older Python 3.x.
AGrzes
pushed a commit
to AGrzes/couchdb
that referenced
this pull request
Nov 2, 2019
The Makefile target builds a python3 venv at .venv and installs black if possible. Since black is Python 3.6 and up only, we skip the check on systems with an older Python 3.x.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Inspired by our formatting work on Elixir, this PR proposes doing the same thing for our Python code.
Python Black is an opinionated code formatter now adopted by prominent Python projects such as
pip
. It is easy to use and provides both formatting and check modes.The
python-black
target builds a python3 venv at .venv and installs black if possible. Since black is Python 3.6 and up only, we skip the check on systems with an older Python 3.x and print a warning. Our CI systems will still catch problems from people who submit PRs who don't have 3.6+ since CI is configured to run this check automatically on at least one platform (e.g., Jenkins Ubuntu Bionic, or Python 3.6 explicitly requested under Travis CI.)Assuming the check runs, it fails if any file would be changed by the formatter.
A Makefile target is provided that actually does the updating (
make python-black-update
, it simply omits the--check
flag) for happy dev fingers to fix up python files.The change to the
docs
dependency inrebar.config.script
is necessary because of embedded Python files in that repo that have only just been re-formatted. Once docs is tagged with 2.3.0, this dep will be reverted to a tag-type reference, not a commit.@nickva I had to change the location of the Mango venv to
src/mango/.venv
so it would be automatically ignored by the formatter, otherwise it tries to format the entire venv. Oops :)Testing recommendations
If you have Python 3.6+, try
make python-black
and see if it works.if you don't, try the same command and make sure it is a noop (with an exit code of 0).
Checklist