[Python-checkins] typing docs: Add example for async functions (#20386)
JelleZijlstra
webhook-mailer at python.org
Sun May 1 00:40:37 EDT 2022
https://github.com/python/cpython/commit/9588f880a286a8cc5597188f6ab44108c8f18761
commit: 9588f880a286a8cc5597188f6ab44108c8f18761
branch: main
author: Sam Bull <aa6bs0 at sambull.org>
committer: JelleZijlstra <jelle.zijlstra at gmail.com>
date: 2022-04-30T22:40:27-06:00
summary:
typing docs: Add example for async functions (#20386)
Fixes python/typing#424
files:
M Doc/library/typing.rst
diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst
index 426cbf12b8c92..868ea1b81be42 100644
--- a/Doc/library/typing.rst
+++ b/Doc/library/typing.rst
@@ -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]``.
More information about the Python-checkins
mailing list