Skip to content

bpo-33064: lib2to3: support trailing comma after **kwargs#6096

Merged
ambv merged 4 commits into
python:masterfrom
ambv:lib2to3-trailing
Mar 13, 2018
Merged

bpo-33064: lib2to3: support trailing comma after **kwargs#6096
ambv merged 4 commits into
python:masterfrom
ambv:lib2to3-trailing

Conversation

@ambv

@ambv ambv commented Mar 13, 2018

Copy link
Copy Markdown
Contributor

Title says it like it is.

I also made the comments in line with the builtin Grammar/Grammar. PEP 306 was
withdrawn, Kees Blom's railroad program has been lost to the sands of time for
at least 16 years now (I found a python-dev post from people looking for it).

It would be actually nice to make the rest of the grammar uniform with Grammar/Grammar whenever possible to be able to diff it easier for omissions. Of course, some differences will always be there to support Python 2 syntax, but a lot could be improved. I'll leave that for a separate commit though.

https://bugs.python.org/issue33064

I also made the comments in line with the builtin Grammar/Grammar. PEP 306 was
withdrawn, Kees Blom's railroad program has been lost to the sands of time for
at least 16 years now (I found a python-dev post from people looking for it).

@ned-deily ned-deily left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No review comments on the grammar changes. Perhaps @benjaminp has an interest in them? Otherwise, the NEWS entry cruft should be removed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some extraneous blurb stuff to remove here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Duh! Fixed :)

@bedevere-bot

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@benjaminp

Copy link
Copy Markdown
Contributor

Grammar change seems okay to me.

@1st1

1st1 commented Mar 13, 2018

Copy link
Copy Markdown
Member

No review comments on the grammar changes.

I actually looked at the changes before approving the PR :)

@ned-deily

Copy link
Copy Markdown
Member

@1st1 I was sure you did. I just meant that I didn't!

@ambv ambv force-pushed the lib2to3-trailing branch from c60850c to 192d2ab Compare March 13, 2018 06:17
@ambv

ambv commented Mar 13, 2018

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again.

@bedevere-bot

Copy link
Copy Markdown

Thanks for making the requested changes!

@ned-deily, @1st1: please review the changes made to this pull request.

@ambv

ambv commented Mar 13, 2018

Copy link
Copy Markdown
Contributor Author

Updated NEWS again, suspicious checker failed on this because there were no backticks around **kwargs.

@serhiy-storchaka

Copy link
Copy Markdown
Member

Any tests?

@ambv

ambv commented Mar 13, 2018

Copy link
Copy Markdown
Contributor Author

Good call, Serhiy, I added some :)

*g:6, h:7, i=8, j:9=10, **k:11) -> 12: pass"""
self.validate(s)

def test_9(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would be nice to add tests for signatures like:

(a,)
(*args,)
(a=1,)

and few combinations if they have a separate path in the grammar.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LOL, that's one subtle way to signal "your patch doesn't handle the vararg case" ;-) Alright, I added *args support, too, and added the relevant tests.

@ambv ambv merged commit b51f5de into python:master Mar 13, 2018
@bedevere-bot

Copy link
Copy Markdown

@ambv: Please replace # with GH- in the commit message next time. Thanks!

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @ambv for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 13, 2018
…ythonGH-6096)

New tests also added.

I also made the comments in line with the builtin Grammar/Grammar. PEP 306 was
withdrawn, Kees Blom's railroad program has been lost to the sands of time for
at least 16 years now (I found a python-dev post from people looking for it).
(cherry picked from commit b51f5de)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
@bedevere-bot

Copy link
Copy Markdown

GH-6097 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 13, 2018
…ythonGH-6096)

New tests also added.

I also made the comments in line with the builtin Grammar/Grammar. PEP 306 was
withdrawn, Kees Blom's railroad program has been lost to the sands of time for
at least 16 years now (I found a python-dev post from people looking for it).
(cherry picked from commit b51f5de)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
@bedevere-bot

Copy link
Copy Markdown

GH-6098 is a backport of this pull request to the 3.6 branch.

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was unsure. The grammar rules are hard to read, tests allow to confirm suspicions.

I have doubts about some combinations. I would add tests for

(a, b)
(a, *b)
(a, b=1)
(a, **b)
(*a, b=1)
(*a, **b)
(*, b=1)
(a=1, b=2)
(a=1, **b)

with and without a trailing comma.

Comment thread Lib/lib2to3/Grammar.txt
typedargslist: ((tfpdef ['=' test] ',')*
('*' [tname] (',' tname ['=' test])* [',' '**' tname] | '**' tname)
('*' [tname] (',' tname ['=' test])* [',' ['**' tname [',']]] | '**' tname [','])
| tfpdef ['=' test] (',' tfpdef ['=' test])* [','])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could it be just tfpdef ['=' test] [',']? Of course may be there are reasons of writing the rule as it is written due to the parser limitations.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe but I want to keep this as close to Grammar/Grammar and this is how it's voiced there.

ambv added a commit that referenced this pull request Mar 13, 2018
…H-6096) (#6097)

New tests also added.

I also made the comments in line with the builtin Grammar/Grammar. PEP 306 was
withdrawn, Kees Blom's railroad program has been lost to the sands of time for
at least 16 years now (I found a python-dev post from people looking for it).
(cherry picked from commit b51f5de)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
ambv added a commit that referenced this pull request Mar 13, 2018
…H-6096) (#6098)

New tests also added.

I also made the comments in line with the builtin Grammar/Grammar. PEP 306 was
withdrawn, Kees Blom's railroad program has been lost to the sands of time for
at least 16 years now (I found a python-dev post from people looking for it).
(cherry picked from commit b51f5de)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
@ambv

ambv commented Mar 13, 2018

Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka, I merged this before I read your comment on the additional tests you'd like to see. I added the combinations you described in a separate pull request (see #6101).

Thanks for your thorough review!

jo2y pushed a commit to jo2y/cpython that referenced this pull request Mar 23, 2018
…ython#6096)

New tests also added.

I also made the comments in line with the builtin Grammar/Grammar. PEP 306 was
withdrawn, Kees Blom's railroad program has been lost to the sands of time for
at least 16 years now (I found a python-dev post from people looking for it).
@ambv ambv deleted the lib2to3-trailing branch July 12, 2021 11:23
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.

8 participants