Skip to content
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

lib2to3 fails on a trailing comma after **kwargs in a function signature #77245

Closed
ambv opened this issue Mar 13, 2018 · 9 comments
Closed

lib2to3 fails on a trailing comma after **kwargs in a function signature #77245

ambv opened this issue Mar 13, 2018 · 9 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes type-bug An unexpected behavior, bug, or error

Comments

@ambv
Copy link
Contributor

ambv commented Mar 13, 2018

BPO 33064
Nosy @ned-deily, @ambv, @serhiy-storchaka
PRs
  • bpo-33064: lib2to3: support trailing comma after **kwargs #6096
  • bpo-33064: lib2to3: support trailing comma after **kwargs #6096
  • [3.7] bpo-33064: lib2to3: support trailing comma after *args and **kwargs (GH-6096) #6097
  • [3.6] bpo-33064: lib2to3: support trailing comma after *args and **kwargs (GH-6096) #6098
  • bpo-33064: lib2to3: Add more tests #6101
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/ambv'
    closed_at = <Date 2018-03-13.22:19:55.107>
    created_at = <Date 2018-03-13.02:50:30.090>
    labels = ['3.8', 'type-bug', '3.7']
    title = 'lib2to3 fails on a trailing comma after **kwargs in a function signature'
    updated_at = <Date 2018-03-13.22:19:55.106>
    user = 'https://github.com/ambv'

    bugs.python.org fields:

    activity = <Date 2018-03-13.22:19:55.106>
    actor = 'lukasz.langa'
    assignee = 'lukasz.langa'
    closed = True
    closed_date = <Date 2018-03-13.22:19:55.107>
    closer = 'lukasz.langa'
    components = []
    creation = <Date 2018-03-13.02:50:30.090>
    creator = 'lukasz.langa'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33064
    keywords = ['patch', 'patch']
    message_count = 9.0
    messages = ['313718', '313719', '313722', '313723', '313724', '313725', '313726', '313728', '313729']
    nosy_count = 3.0
    nosy_names = ['ned.deily', 'lukasz.langa', 'serhiy.storchaka']
    pr_nums = ['6096', '6096', '6097', '6098', '6101']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue33064'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @ambv
    Copy link
    Contributor Author

    ambv commented Mar 13, 2018

    Title says all. I have a patch.

    @ambv ambv added 3.7 (EOL) end of life 3.8 only security fixes labels Mar 13, 2018
    @ambv ambv self-assigned this Mar 13, 2018
    @ambv
    Copy link
    Contributor Author

    ambv commented Mar 13, 2018

    Ned, I'd like this to make into 3.6.5 if at all possible.

    @ambv ambv added the type-bug An unexpected behavior, bug, or error label Mar 13, 2018
    @serhiy-storchaka
    Copy link
    Member

    Does it support a trailing comma after *args or name=value?

    @serhiy-storchaka
    Copy link
    Member

    I'm not sure that a trailing comma after **kwargs in a function signature should be allowed in Python grammar. Reasons for allowing it after other arguments don't work here since **kwargs is always a last item in a signature.

    But this ship perhaps is sailed.

    @ambv
    Copy link
    Contributor Author

    ambv commented Mar 13, 2018

    New changeset b51f5de by Łukasz Langa in branch 'master':
    bpo-33064: lib2to3: support trailing comma after *args and **kwargs (bpo-6096)
    b51f5de

    @ambv
    Copy link
    Contributor Author

    ambv commented Mar 13, 2018

    Yes, this ship has sailed with Python 3.6.

    I understand your logic and this is indeed why we didn't support this for a long time. However, people tend to grow muscle memory to add trailing commas and that was tripping them over for no real gain on our part. So this was added. The reason I found out about lib2to3 not following suit was that 3.6 users quickly started to put those trailing commas in and tools using lib2to3 were crashing on such files :) This proves it was worth it.

    @ambv
    Copy link
    Contributor Author

    ambv commented Mar 13, 2018

    Oh, and in terms of *calling* functions, now we can specify multiple unpacks, like:

      >>> f(
      ...   **d,
      ...   **e,
      ... )

    so the extra comma for signatures simply makes it symmetrical in terms of appearance.

    @ambv
    Copy link
    Contributor Author

    ambv commented Mar 13, 2018

    New changeset b4c8871 by Łukasz Langa (Miss Islington (bot)) in branch '3.7':
    bpo-33064: lib2to3: support trailing comma after *args and **kwargs (GH-6096) (bpo-6097)
    b4c8871

    @ambv
    Copy link
    Contributor Author

    ambv commented Mar 13, 2018

    New changeset 6a526f6 by Łukasz Langa (Miss Islington (bot)) in branch '3.6':
    bpo-33064: lib2to3: support trailing comma after *args and **kwargs (GH-6096) (bpo-6098)
    6a526f6

    @ambv ambv closed this as completed Mar 13, 2018
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants