Typing and Generics
typing.Coroutine
A coroutine interface with send, throw and close operations and an await result type. For async def annotations use the eventual result type, not Coroutine itself. Deprecated typing alias; prefer collections.abc.Coroutine in modern code (3.9+).
Formal Syntax & Structure
python syntaxpython
typing.Coroutine[YieldType, SendType, ReturnType]Return Value
type expression
Typing construct or runtime result as described; static typing rules are not runtime validation.
Working Example
Example Snippetpython
from typing import Coroutine
import asyncioasync def produce()->int: return 9async def read(coro:Coroutine[object,None,int])->int: return await coroasync def main(): return await read(produce())print(asyncio.run(main()))