Skip to content

Conversation

@ilevkivskyi
Copy link
Member

@ilevkivskyi ilevkivskyi commented Jun 2, 2019

cc @gvanrossum @rhettinger

Btw, when writing this I am now thinking is there a reason why we don't allow also star expressions in the r.h.s. of annotated assignments (so that it mirrors normal assignment, not augmented assignment)? For example t: Tuple[int, ...] = x, y, *z is a SyntaxError. Should we try allowing this? Or is it too late in the release cycle?

https://bugs.python.org/issue35814

@ilevkivskyi
Copy link
Member Author

See python/peps#1096 for the corresponding PEP update.

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Re: whether to allow x, y, *z on the RHS, I guess PEP 526 again doesn't specify this either way. I vaguely recall that during the discussion we weren't too sure about various extensions, but perhaps the most important thing we didn't want to allow was multiple variables (e.g. x, y: int would be ambiguous).

I'm okay with allowing that, and it's probably better to do it sooner than later. The fix presumably is very simple (just update the grammar) but I'd request a test to make sure we didn't miss anything obvious in the code generation. (But x: Tuple[int, ...] = (1, 2, *xs) does work, so probably nothing.)

@ilevkivskyi
Copy link
Member Author

OK, I will make a separate PR tomorrow (it is almost 1AM here).

@ilevkivskyi ilevkivskyi merged commit 82eac26 into python:master Jun 2, 2019
@ilevkivskyi ilevkivskyi deleted the update-annasign-docs branch June 2, 2019 23:41
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants