Skip to content

Commit a66be91

Browse files
[3.10] bpo-46104: Reduce use of pre-PEP 526 syntax in typing docs (GH-30148) (GH-30179)
Co-authored-by: Andrew Svetlov <[email protected]> (cherry picked from commit 6ada013) Co-authored-by: Alex Waygood <[email protected]>
1 parent dbd1dc2 commit a66be91

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

Doc/library/typing.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -428,12 +428,12 @@ value of type :data:`Any` and assign it to any variable::
428428

429429
from typing import Any
430430

431-
a = None # type: Any
432-
a = [] # OK
433-
a = 2 # OK
431+
a: Any = None
432+
a = [] # OK
433+
a = 2 # OK
434434

435-
s = '' # type: str
436-
s = a # OK
435+
s = '' # Inferred type of 's' is str
436+
s = a # OK
437437

438438
def foo(item: Any) -> int:
439439
# Typechecks; 'item' could be any type,
@@ -1779,11 +1779,10 @@ Asynchronous programming
17791779
correspond to those of :class:`Generator`, for example::
17801780

17811781
from collections.abc import Coroutine
1782-
c = None # type: Coroutine[list[str], str, int]
1783-
...
1784-
x = c.send('hi') # type: list[str]
1782+
c: Coroutine[list[str], str, int] # Some coroutine defined elsewhere
1783+
x = c.send('hi') # Inferred type of 'x' is list[str]
17851784
async def bar() -> None:
1786-
x = await c # type: int
1785+
y = await c # Inferred type of 'y' is int
17871786

17881787
.. versionadded:: 3.5.3
17891788

0 commit comments

Comments
 (0)