]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
typing docs: Add example for async functions (#20386)
authorSam Bull <aa6bs0@sambull.org>
Sun, 1 May 2022 04:40:27 +0000 (05:40 +0100)
committerGitHub <noreply@github.com>
Sun, 1 May 2022 04:40:27 +0000 (22:40 -0600)
Fixes python/typing#424

Doc/library/typing.rst

index 426cbf12b8c926264868016be4de8e397a16a054..868ea1b81be4228b11798c242ba9a72ef1f589b0 100644 (file)
@@ -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]``.