typing docs: Add example for async functions (#20386)

Fixes python/typing#424
This commit is contained in:
Sam Bull 2022-05-01 05:40:27 +01:00 committed by GitHub
parent 1066ecb970
commit 9588f880a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -221,6 +221,10 @@ For example::
on_error: Callable[[int, Exception], None]) -> None:
# Body
async def on_update(value: str) -> None:
# Body
callback: Callable[[str], Awaitable[None]] = on_update
It is possible to declare the return type of a callable without specifying
the call signature by substituting a literal ellipsis
for the list of arguments in the type hint: ``Callable[..., ReturnType]``.