Typing and Generics

typing.AsyncIterator

An asynchronous iterator that provides __anext__ and returns itself from __aiter__. Each anext operation is awaitable. Deprecated typing alias; prefer collections.abc.AsyncIterator in modern code (3.9+).

Formal Syntax & Structure

python syntaxpython
typing.AsyncIterator[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 AsyncIterator
import asyncioasync def values()->AsyncIterator[int]:    yield 4async def read():    it=values()    return await anext(it), await anext(it,None)print(asyncio.run(read()))
Python Reference