mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
typing docs: Add example for async functions (#20386)
Fixes python/typing#424
This commit is contained in:
parent
1066ecb970
commit
9588f880a2
1 changed files with 4 additions and 0 deletions
|
@ -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]``.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue