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

Wrong generated annotation on subscripting #84840

Closed
isidentical opened this issue May 17, 2020 · 5 comments
Closed

Wrong generated annotation on subscripting #84840

isidentical opened this issue May 17, 2020 · 5 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@isidentical
Copy link
Sponsor Member

BPO 40663
Nosy @pablogsal, @miss-islington, @isidentical
PRs
  • bpo-40663: Correctly generate annotations for subscripts #20156
  • [3.8] bpo-40663: Correctly handle annotations with subscripts in ast_… #20191
  • [3.7] bpo-40663: Correctly handle annotations with subscripts in ast_… #20192
  • [3.9] bpo-40663: Correctly handle annotations with subscripts in ast_unparse.c (GH-20156) #20324
  • 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 = None
    closed_at = <Date 2020-05-22.22:37:43.072>
    created_at = <Date 2020-05-17.17:36:39.000>
    labels = ['interpreter-core', '3.8', 'type-bug', '3.7', '3.9']
    title = 'Wrong generated annotation on subscripting'
    updated_at = <Date 2020-05-22.22:37:43.071>
    user = 'https://github.com/isidentical'

    bugs.python.org fields:

    activity = <Date 2020-05-22.22:37:43.071>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-05-22.22:37:43.072>
    closer = 'pablogsal'
    components = ['Interpreter Core']
    creation = <Date 2020-05-17.17:36:39.000>
    creator = 'BTaskaya'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40663
    keywords = ['patch']
    message_count = 5.0
    messages = ['369140', '369141', '369283', '369664', '369665']
    nosy_count = 3.0
    nosy_names = ['pablogsal', 'miss-islington', 'BTaskaya']
    pr_nums = ['20156', '20191', '20192', '20324']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue40663'
    versions = ['Python 3.7', 'Python 3.8', 'Python 3.9']

    @isidentical
    Copy link
    Sponsor Member Author

    >>> from __future__ import annotations
    >>> a: Type[int, str]
    >>> b: Type[(int, str, *types)]
    >>> __annotations__
    {'a': 'Type[int, str]', 'b': 'Type[int, str, *types]'}
    >>> ast.parse(__annotations__["b"])
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/isidentical/cpython/master/Lib/ast.py", line 50, in parse
        return compile(source, filename, mode, flags,
      File "<unknown>", line 1
        Type[int, str, *types]
                       ^
    SyntaxError: invalid syntax

    @isidentical
    Copy link
    Sponsor Member Author

    $ python3.8
    Python 3.8.0+ (heads/3.8:b9e5547f58, Nov 28 2019, 19:18:03) 
    [GCC 9.2.1 20191008] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from __future__ import annotations
    >>> b: Type[(int, str, *types)]
    >>> __annotations__
    {'b': 'Type[int, str, *types]'}
    
     $ python3.7
    Python 3.7.5 (default, Apr 19 2020, 20:18:17) 
    [GCC 9.2.1 20191008] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from __future__ import annotations
    >>> b: Type[(int, str, *types)]
    >>> __annotations__
    {'b': 'Type[int, str, *types]'}
    >>>

    @isidentical isidentical added interpreter-core (Objects, Python, Grammar, and Parser dirs) 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes type-bug An unexpected behavior, bug, or error labels May 17, 2020
    @pablogsal
    Copy link
    Member

    New changeset 2135e10 by Batuhan Taskaya in branch 'master':
    bpo-40663: Correctly handle annotations with subscripts in ast_unparse.c (GH-20156)
    2135e10

    @pablogsal
    Copy link
    Member

    New changeset 4330014 by Batuhan Taskaya in branch '3.7':
    [3.7] bpo-40663: Correctly handle annotations with subscripts in ast_unparse.c (GH-20156). (GH-20192)
    4330014

    @pablogsal
    Copy link
    Member

    New changeset a4d219b by Batuhan Taskaya in branch '3.8':
    [3.8] bpo-40663: Correctly handle annotations with subscripts in ast_unparse.c (GH-20156). (GH-20191)
    a4d219b

    @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 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants