Typing and Generics

typing.Awaitable

An object usable with await that produces T on completion. Not every awaitable is a native coroutine object. Deprecated typing alias; prefer collections.abc.Awaitable in modern code (3.9+).

Formal Syntax & Structure

python syntaxpython
typing.Awaitable[T]

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 Awaitable
import asyncioasync def produce()->int: return 8async def read(value:Awaitable[int])->int: return await valueasync def main(): return await read(produce())print(asyncio.run(main()))
Python Reference