[New-bugs-announce] [issue38978] Implement __class_getitem__ for Future, Task, Queue

Andrew Svetlov report at bugs.python.org
Thu Dec 5 07:53:23 EST 2019

New submission from Andrew Svetlov <andrew.svetlov at gmail.com>:

Typeshed declares asyncio.Future, asyncio.Task and asyncio.Queue as generic types, which is 100% correct.

The problem is that these classes don't support generic instantiation in runtime, e.g. Future[str] raises TypeError.

The feature should be implemented by adding __class_getitem__ methods which return self.

The patch is trivial but requires a few lines of C code for C Accelerated CTask and CFuture as well as updating Python code.

A volunteer is welcome!

components: asyncio
keywords: easy, easy (C)
messages: 357848
nosy: asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: Implement __class_getitem__ for Future, Task, Queue
versions: Python 3.9

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list