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.

Title: asyncio Generic classes should return GenericAlias in __class_getitem__
Type: behavior Stage: resolved
Components: Versions: Python 3.11, Python 3.10, Python 3.9
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, kumaraditya, miss-islington, yselivanov
Priority: normal Keywords: patch

Created on 2022-01-22 04:41 by kumaraditya, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 30777 merged kumaraditya, 2022-01-22 05:01
PR 30784 merged miss-islington, 2022-01-22 11:29
PR 30785 merged kumaraditya, 2022-01-22 11:41
Messages (4)
msg411231 - (view) Author: Kumar Aditya (kumaraditya) * (Python triager) Date: 2022-01-22 04:41
In asyncio, the Generic classes return the class itself in __class_getitem__ instead of GenericAlias, because of this they cannot be introspected as GenericAlias objects.

Running Debug|x64 interpreter...
Python 3.11.0a4+ (main, Jan 22 2022, 10:00:18) [MSC v.1930 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> asyncio.Future
<class '_asyncio.Future'>
>>> asyncio.Future[int] 
<class '_asyncio.Future'>
>>> list
<class 'list'>
>>> list[int]
>>> list[int].__args__
(<class 'int'>,)
>>> asyncio.Future[int].__args__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object '_asyncio.Future' has no attribute '__args__'
msg411249 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2022-01-22 11:29
New changeset ea5b96842e066623a53015d8b2492ed61a5baf96 by Kumar Aditya in branch 'main':
bpo-46469: Make asyncio generic classes return GenericAlias (GH-30777)
msg411251 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2022-01-22 12:28
New changeset 90e2998db78cd15e45b3c82f6360ac8841e03945 by Miss Islington (bot) in branch '3.10':
[3.10] bpo-46469: Make asyncio generic classes return GenericAlias (GH-30777) (#30784)
msg411254 - (view) Author: miss-islington (miss-islington) Date: 2022-01-22 12:52
New changeset 6ed874f8c59cc6c01d9663bad2f4bed8dc1c6109 by Kumar Aditya in branch '3.9':
[3.9] bpo-46469: Make asyncio generic classes return GenericAlias (GH-30777)  (GH-30785)
Date User Action Args
2022-04-11 14:59:55adminsetgithub: 90627
2022-01-22 14:10:04asvetlovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-01-22 12:52:29miss-islingtonsetmessages: + msg411254
2022-01-22 12:28:57asvetlovsetmessages: + msg411251
2022-01-22 11:47:44kumaradityasetversions: + Python 3.9, Python 3.10
2022-01-22 11:41:42kumaradityasetpull_requests: + pull_request28970
2022-01-22 11:29:19asvetlovsetmessages: + msg411249
2022-01-22 11:29:03miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request28969
2022-01-22 05:01:41kumaradityasetkeywords: + patch
stage: patch review
pull_requests: + pull_request28962
2022-01-22 04:41:15kumaradityacreate