mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
a48d31f204
commit
e7de543219
1 changed files with 4 additions and 0 deletions
|
@ -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]``.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue