[Python-checkins] typing docs: Add example for async functions (GH-20386)

miss-islington webhook-mailer at python.org
Sun May 1 00:56:02 EDT 2022


https://github.com/python/cpython/commit/e7de54321952ebb58cc414f2160c9ad4f6510af2
commit: e7de54321952ebb58cc414f2160c9ad4f6510af2
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-04-30T21:55:58-07:00
summary:

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


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

Co-authored-by: Sam Bull <aa6bs0 at sambull.org>

files:
M Doc/library/typing.rst

diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst
index 36d637f366509..6a160af895c06 100644
--- a/Doc/library/typing.rst
+++ b/Doc/library/typing.rst
@@ -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]``.



More information about the Python-checkins mailing list