This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Wrong generated annotation on subscripting
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: BTaskaya, miss-islington, pablogsal
Priority: normal Keywords: patch

Created on 2020-05-17 17:36 by BTaskaya, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 20156 merged BTaskaya, 2020-05-17 17:41
PR 20191 merged BTaskaya, 2020-05-18 19:35
PR 20192 merged BTaskaya, 2020-05-18 19:44
PR 20324 closed miss-islington, 2020-05-22 22:32
Messages (5)
msg369140 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-05-17 17:36
>>> 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
msg369141 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-05-17 17:41
$ 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]'}
>>>
msg369283 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-05-18 18:23
New changeset 2135e10dc717c00d10d899d232bebfc59bb25032 by Batuhan Taskaya in branch 'master':
bpo-40663: Correctly handle annotations with subscripts in ast_unparse.c (GH-20156)
https://github.com/python/cpython/commit/2135e10dc717c00d10d899d232bebfc59bb25032
msg369664 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-05-22 22:32
New changeset 43300148c5f30317ebf767aa8853a957ee5c87fb by Batuhan Taskaya in branch '3.7':
[3.7] bpo-40663: Correctly handle annotations with subscripts in ast_unparse.c (GH-20156). (GH-20192)
https://github.com/python/cpython/commit/43300148c5f30317ebf767aa8853a957ee5c87fb
msg369665 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-05-22 22:32
New changeset a4d219b35e35f9efc406cd70f2812275bcd989fe by Batuhan Taskaya in branch '3.8':
[3.8] bpo-40663: Correctly handle annotations with subscripts in ast_unparse.c (GH-20156). (GH-20191)
https://github.com/python/cpython/commit/a4d219b35e35f9efc406cd70f2812275bcd989fe
History
Date User Action Args
2022-04-11 14:59:31adminsetgithub: 84840
2020-05-22 22:37:43pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-05-22 22:32:44pablogsalsetmessages: + msg369665
2020-05-22 22:32:37pablogsalsetmessages: + msg369664
2020-05-22 22:32:03miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request19593
2020-05-18 19:44:00BTaskayasetpull_requests: + pull_request19493
2020-05-18 19:35:25BTaskayasetpull_requests: + pull_request19492
2020-05-18 18:23:53pablogsalsetnosy: + pablogsal
messages: + msg369283
2020-05-17 17:42:21BTaskayasettype: behavior
components: + Interpreter Core
versions: + Python 3.7, Python 3.8, Python 3.9
2020-05-17 17:41:52BTaskayasetmessages: + msg369141
2020-05-17 17:41:03BTaskayasetkeywords: + patch
stage: patch review
pull_requests: + pull_request19459
2020-05-17 17:36:39BTaskayacreate