typing docs: Add example for async functions (GH-20386)

Fixes python/typingGH-424
(cherry picked from commit 9588f880a2)

Co-authored-by: Sam Bull <aa6bs0@sambull.org>
This commit is contained in:
Miss Islington (bot) 2022-04-30 21:55:58 -07:00 committed by GitHub
parent a48d31f204
commit e7de543219
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -211,6 +211,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]``.