@@ -1254,7 +1254,20 @@ type of ``await`` expression, not to the coroutine type::
1254
1254
async def foo() -> None:
1255
1255
bar = await spam(42) # type: str
1256
1256
1257
- The ``typing.py`` module also provides generic ABCs ``Awaitable``,
1257
+ The ``typing.py`` module provides a generic version of ABC
1258
+ ``collections.abc.Coroutine`` to specify awaitables that also support
1259
+ ``send()`` and ``throw()`` methods. The variance and order of type variables
1260
+ correspond to those of ``Generator``, namely ``Coroutine[T_co, T_contra, V_co]``,
1261
+ for example::
1262
+
1263
+ from typing import List, Coroutine
1264
+ c = None # type: Coroutine[List[str], str, int]
1265
+ ...
1266
+ x = c.send('hi') # type: List[str]
1267
+ async def bar(): -> None:
1268
+ x = await c # type: int
1269
+
1270
+ The module also provides generic ABCs ``Awaitable``,
1258
1271
``AsyncIterable``, and ``AsyncIterator`` for situations where more precise
1259
1272
types cannot be specified::
1260
1273
@@ -1768,10 +1781,14 @@ Generic variants of container ABCs (and a few non-containers):
1768
1781
1769
1782
* Callable (see above, listed here for completeness)
1770
1783
1784
+ * Collection
1785
+
1771
1786
* Container
1772
1787
1773
1788
* ContextManager
1774
1789
1790
+ * Coroutine
1791
+
1775
1792
* Generator, used as ``Generator[yield_type, send_type,
1776
1793
return_type]``. This represents the return value of generator
1777
1794
functions. It is a subtype of ``Iterable`` and it has additional
0 commit comments