Skip to content

Conversation

@wchargin
Copy link
Contributor

@wchargin wchargin commented Mar 3, 2020

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 a
parser bug (https://bugs.python.org/issue9232) when trailing commas
are used with this syntax, as in def foo(x, *, y,). This is fixed in
Python 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.toml prevents Black from re-introducing these
trailing commas. We leave py27 in the pyproject.toml to avoid a mass
reformat removing u-prefixes from Unicode string literals (which is
fine, 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_called and that json.loads
does not accept bytes). For now, it suffices to run flake8 on both
Python 3.5 and Python 3.7, because that at least parses all the code.

Test Plan:
That CI passes suffices.

wchargin-branch: py35-fundefs

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 a
parser bug (<https://bugs.python.org/issue9232>) when trailing commas
are used with this syntax, as in `def foo(x, *, y,)`. This is fixed in
Python 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.toml` prevents Black from re-introducing these
trailing commas. We leave `py27` in the `pyproject.toml` to avoid a mass
reformat removing `u`-prefixes from Unicode string literals (which is
fine, but should be a separate change for `.git-blame-ignore-revs`).

We don’t run our full test suite on Python 3.5 yet, due to unrelated
issues (primarily, lack of `assert_not_called` and that `json.loads`
does not accept `bytes`). For now, it suffices to run `flake8` on both
Python 3.5 and Python 3.7, because that at least parses all the code.

Test Plan:
That CI passes suffices.

wchargin-branch: py35-fundefs
Copy link
Contributor

@nfelt nfelt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Running just flake8 on py3.5 seems like a good compromise to me :)


jobs:
lint-python:
lint-flake8:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe call this lint-python-flake8 just to be clear to the uninitiated that it's also linting python? Since otherwise separating it out from lint-python is a little confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure; fine with me. Done.

wchargin-branch: py35-fundefs
wchargin-source: 95560cf6984706951dbc83732c1c2b83dd871c3d
@wchargin wchargin merged commit a78a585 into master Mar 3, 2020
@wchargin wchargin deleted the wchargin-py35-fundefs branch March 3, 2020 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants