Skip to content

Commit

Permalink
[3.9] bpo-46104: Reduce use of pre-PEP 526 syntax in typing docs (GH-…
Browse files Browse the repository at this point in the history
…30148) (GH-30180)

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


Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
  • Loading branch information
miss-islington and AlexWaygood committed Dec 18, 2021
1 parent 8202a7e commit 43cb8f4
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions Doc/library/typing.rst
Expand Up @@ -358,12 +358,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,
Expand Down Expand Up @@ -1445,11 +1445,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

Expand Down

0 comments on commit 43cb8f4

Please sign in to comment.