Add the black
Python code formatter
#4313
Merged
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.
Description
It's silly how many code review comments are about formatting of Python code. Mechanical things like that are the job of computers, not human reviewers. For many years, there were many competing Python code formatters. However, in the last couple of years, the Python community has come to a realization that the Go community realized from the get-go: Agreement on the formatter is more important than the formatting itself. That even if the formatting isn't your favorite, that not having to have discussions about formatting is even better. So the Python community has standardized on the
black
formatter.So adopt
black
the way we've adoptedgofmt
!make format/black
(running justmake format
would do this and a few other things too)That last commit, while being machine-generated, is probably still worthy of decent scrutiny, to make sure it didn't move around a comment to where it's not near the code it's describing, or something funny like that.
I considered turning parts of black off, and only re-formatting things incrementally over time, so as to avoid merge-conflicts with current in-flight Python work. While tempting, there's still no good time to turn each thing on, so I figure it's better to just bite the bullet and get it over with rather than drawing it out over months.
Checklist
I made sure to update
CHANGELOG.md
. - no applicable changesRemember, the CHANGELOG needs to mention:
This is unlikely to impact how Ambassador performs at scale.
Remember, things that might have an impact at scale include:
My change is adequately tested.
Remember when considering testing:
I updated
DEVELOPING.md
with any any special dev tricks I had to use to work on this code efficiently. - no tricks (no new trucks,make lint
is still the way to have formatting mistakes caught, andmake format
is still the way to fix them in and automated fashion)The changes in this PR have been reviewed for security concerns and adherence to security best practices.