Use cPython 3.5–compatible function definitions #3320
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.
Summary:
In Python as of PEP 3102, function definitions may include keyword-only
arguments after a splat (
def foo(x, *, y)). But cPython 3.5 has aparser bug (https://bugs.python.org/issue9232) when trailing commas
are used with this syntax, as in
def foo(x, *, y,). This is fixed inPython 3.6 and up, but not backported to 3.5, so for now we should make
sure to omit these trailing commas.
The change to
pyproject.tomlprevents Black from re-introducing thesetrailing commas. We leave
py27in thepyproject.tomlto avoid a massreformat removing
u-prefixes from Unicode string literals (which isfine, but should be a separate change for Bazel
srcs_version).We don’t run our full test suite on Python 3.5 yet, due to unrelated
issues (primarily, lack of
assert_not_calledand thatjson.loadsdoes not accept
bytes). For now, it suffices to runflake8on bothPython 3.5 and Python 3.7, because that at least parses all the code.
Test Plan:
That CI passes suffices.
wchargin-branch: py35-fundefs