Format and check all Python code using python black#1776
Merged
Conversation
160c2ca to
be6c902
Compare
jaydoane
reviewed
Nov 29, 2018
davisp
reviewed
Dec 6, 2018
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.
This file contains hidden or 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
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-blacktarget 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--checkflag) for happy dev fingers to fix up python files.The change to the
docsdependency inrebar.config.scriptis 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/.venvso 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-blackand 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