Skip to content

Commit

Permalink
typing docs: Add example for async functions (python#20386)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer authored May 1, 2022
1 parent 1066ecb commit 9588f88
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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]``.
Expand Down

0 comments on commit 9588f88

Please sign in to comment.