]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
typing docs: Add example for async functions (GH-20386)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 1 May 2022 04:59:26 +0000 (21:59 -0700)
committerGitHub <noreply@github.com>
Sun, 1 May 2022 04:59:26 +0000 (21:59 -0700)
Fixes python/typingGH-424
(cherry picked from commit 9588f880a286a8cc5597188f6ab44108c8f18761)

Co-authored-by: Sam Bull <aa6bs0@sambull.org>
Doc/library/typing.rst

index 202f5b5e8fec4c5b0f9017d1fc7a229cc0c49520..c0af2ed7c429aef5d02a3fb9d0e0147be748dc75 100644 (file)
@@ -194,6 +194,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]``.