summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Waygood <Alex.Waygood@Gmail.com>2021-12-18 10:23:51 (GMT)
committerGitHub <noreply@github.com>2021-12-18 10:23:51 (GMT)
commit6ada013df170b0afb6b61a0d942388c6fd81cbc9 (patch)
treee804f09925edcb6fa5319c6469777d460cc2bb00
parentda8cf8a74714f4cc34fb768345cb1caf9dcddd62 (diff)
downloadcpython-6ada013df170b0afb6b61a0d942388c6fd81cbc9.zip
cpython-6ada013df170b0afb6b61a0d942388c6fd81cbc9.tar.gz
cpython-6ada013df170b0afb6b61a0d942388c6fd81cbc9.tar.bz2
bpo-46104: Reduce use of pre-PEP 526 syntax in typing docs (GH-30148)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
-rw-r--r--Doc/library/typing.rst17
1 files changed, 8 insertions, 9 deletions
diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst
index 735d477..ec1b8d1 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