Skip to content

bpo-35814: Allow same r.h.s. in annotated assignments as in normal ones#11667

Merged
ilevkivskyi merged 6 commits intopython:masterfrom
ilevkivskyi:fix-annotation-tuple
Jan 25, 2019
Merged

bpo-35814: Allow same r.h.s. in annotated assignments as in normal ones#11667
ilevkivskyi merged 6 commits intopython:masterfrom
ilevkivskyi:fix-annotation-tuple

Conversation

@ilevkivskyi
Copy link
Copy Markdown
Member

@ilevkivskyi ilevkivskyi commented Jan 24, 2019

@ilevkivskyi
Copy link
Copy Markdown
Member Author

Should we also backport this to 3.7?

@ilevkivskyi
Copy link
Copy Markdown
Member Author

Hm, actually there was an old test checking that x: tuple = 1, 2 fails with syntax error. So maybe it was actually a conscious decision to prohibit this. I don't remember. Anyway, I don't have a strong preference here, so @gvanrossum @rhettinger I leave the decision up to you.

@ilevkivskyi
Copy link
Copy Markdown
Member Author

OK, after more careful reading of PEP 526, I found this:

Only single assignment targets and single right hand side values are allowed.

So it was a deliberate decision. The PEP is final now, so I would propose to just close this, unles @rhettinger really thinks we need to allow omitting parentheses.

@gvanrossum
Copy link
Copy Markdown
Member

This was meant to guard against interpretations like

var1: type = 1, var2 = 2

@gvanrossum
Copy link
Copy Markdown
Member

Sorry, too soon.

I think that worry was unneeded and agree with Raymond.

We can change it in 3.8 but no backport.

@ilevkivskyi
Copy link
Copy Markdown
Member Author

This was meant to guard against interpretations like var1: type = 1, var2 = 2

I think it would make sense to add a tests that this particular code still fails.

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

Successfully merging this pull request may close these issues.

4 participants