Typing and Generics

typing.AsyncIterable

A source supporting async iteration, which need not itself be an asynchronous iterator. Deprecated typing alias; prefer collections.abc.AsyncIterable in modern code (3.9+).

Formal Syntax & Structure

python syntaxpython
typing.AsyncIterable[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 AsyncIterable
import asyncioasync def values():    yield 2    yield 5async def total(source: AsyncIterable[int])->int:    return sum([n async for n in source])print(asyncio.run(total(values())))
Python Reference