On this page
typing.AsyncGenerator
Prev: typing.AsyncContextManager | Up: typing | Next: typing.AsyncIterable
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.AsyncGenerator
Tags: #public #python3 #stdlib #typing
Import
import typing
from typing import AsyncGenerator
Signature & Overview
typing.AsyncGenerator(*args, **kwargs)
Deprecated alias to collections.abc.AsyncGenerator.
Usage
from typing import AsyncGenerator
async def counter(n: int) -> AsyncGenerator[int, None]:
for i in range(n):
yield i
assert callable(counter)
Gotchas
- Type parameters are
[YieldType, SendType]: Prefercollections.abc.AsyncGenerator[int, None](orAsyncIterator[int]if.asend()isn't used).
REPL Inspect
from typing import AsyncGenerator
help(AsyncGenerator)
Linked from
Related notes
- tuts/python3/stdlib_module/typing/AsyncContextManager Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/AsyncIterable Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/typing/AbstractSet Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Annotated Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Any Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/assert_never Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/assert_type shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/AsyncIterator shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Awaitable shared tags: #stdlib, #typing