[Python-checkins] [3.10] bpo-46104: Reduce use of pre-PEP 526 syntax in typing docs (GH-30148) (GH-30179)

miss-islington webhook-mailer at python.org
Sat Dec 18 07:14:29 EST 2021


https://github.com/python/cpython/commit/a66be9185c6e0299293a06e21a6f599dfe6c3f60
commit: a66be9185c6e0299293a06e21a6f599dfe6c3f60
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: 2021-12-18T04:14:25-08:00
summary:

[3.10] bpo-46104: Reduce use of pre-PEP 526 syntax in typing docs (GH-30148) (GH-30179)



Co-authored-by: Andrew Svetlov <andrew.svetlov at gmail.com>
(cherry picked from commit 6ada013df170b0afb6b61a0d942388c6fd81cbc9)


Co-authored-by: Alex Waygood <Alex.Waygood at Gmail.com>

files:
M Doc/library/typing.rst

diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst
index 14e5c8fc7efea..c154364ee56ec 100644
--- a/Doc/library/typing.rst
+++ b/Doc/library/typing.rst
@@ -428,12 +428,12 @@ value of type :data:`Any` and assign it to any variable::
 
    from typing import Any
 
-   a = None    # type: Any
-   a = []      # OK
-   a = 2       # OK
+   a: Any = None
+   a = []          # OK
+   a = 2           # OK
 
-   s = ''      # type: str
-   s = a       # OK
+   s = ''          # Inferred type of 's' is str
+   s = a           # OK
 
    def foo(item: Any) -> int:
        # Typechecks; 'item' could be any type,
@@ -1779,11 +1779,10 @@ Asynchronous programming
    correspond to those of :class:`Generator`, for example::
 
       from collections.abc import Coroutine
-      c = None # type: Coroutine[list[str], str, int]
-      ...
-      x = c.send('hi') # type: list[str]
+      c: Coroutine[list[str], str, int]  # Some coroutine defined elsewhere
+      x = c.send('hi')                   # Inferred type of 'x' is list[str]
       async def bar() -> None:
-          x = await c # type: int
+          y = await c                    # Inferred type of 'y' is int
 
    .. versionadded:: 3.5.3
 



More information about the Python-checkins mailing list