Skip to content

Comma causes syntax error in i2c_device.py #56

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

Closed
phil-shenk opened this issue Jul 27, 2020 · 3 comments
Closed

Comma causes syntax error in i2c_device.py #56

phil-shenk opened this issue Jul 27, 2020 · 3 comments

Comments

@phil-shenk
Copy link
Contributor

Comma after last argument in 'write_then_readinto' function on line 113 throws syntax error on line 114 in i2c_device.py
python 3.5
proposed fix: delete comma (worked for us)

@dhalbert
Copy link
Contributor

The simplest test case is:

def f(x,): pass      # works
def g(*, x,): pass    # raises SyntaxError

This was fixed in Python 3.6: https://bugs.python.org/issue9232: Allow trailing comma in any function argument list.

We use the black code formatter, which by default inserts commas on all argument lines when the arguments are split across multiple lines, and we require that all code is formatted using black. So we'd have to reformat code in all our libraries using Python 3.5 syntax (black --target-version py35), to suppress this behavior. That would cause other issues with Python syntax we have that is past 3.5.

Are you able to upgrade past Python 3.5? I'm sorry this has happened to you, but I don't think we can accommodate this in all our libraries.

@dhalbert
Copy link
Contributor

OK, I'm sorry, I take this back. We are using black --target-version py35: I had forgotten that.

@dhalbert
Copy link
Contributor

Fixed by #57.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants