mirror of
https://github.com/python/cpython.git
synced 2025-09-29 11:45:57 +00:00
bpo-46104: Reduce use of pre-PEP 526 syntax in typing docs (GH-30148)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
This commit is contained in:
parent
da8cf8a747
commit
6ada013df1
1 changed files with 8 additions and 9 deletions
|
@ -428,11 +428,11 @@ value of type :data:`Any` and assign it to any variable::
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
a = None # type: Any
|
a: Any = None
|
||||||
a = [] # OK
|
a = [] # OK
|
||||||
a = 2 # OK
|
a = 2 # OK
|
||||||
|
|
||||||
s = '' # type: str
|
s = '' # Inferred type of 's' is str
|
||||||
s = a # OK
|
s = a # OK
|
||||||
|
|
||||||
def foo(item: Any) -> int:
|
def foo(item: Any) -> int:
|
||||||
|
@ -1779,11 +1779,10 @@ Asynchronous programming
|
||||||
correspond to those of :class:`Generator`, for example::
|
correspond to those of :class:`Generator`, for example::
|
||||||
|
|
||||||
from collections.abc import Coroutine
|
from collections.abc import Coroutine
|
||||||
c = None # type: Coroutine[list[str], str, int]
|
c: Coroutine[list[str], str, int] # Some coroutine defined elsewhere
|
||||||
...
|
x = c.send('hi') # Inferred type of 'x' is list[str]
|
||||||
x = c.send('hi') # type: list[str]
|
|
||||||
async def bar() -> None:
|
async def bar() -> None:
|
||||||
x = await c # type: int
|
y = await c # Inferred type of 'y' is int
|
||||||
|
|
||||||
.. versionadded:: 3.5.3
|
.. versionadded:: 3.5.3
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue