File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -428,12 +428,12 @@ value of type :data:`Any` and assign it to any variable::
428
428
429
429
from typing import Any
430
430
431
- a = None # type: Any
432
- a = [] # OK
433
- a = 2 # OK
431
+ a: Any = None
432
+ a = [] # OK
433
+ a = 2 # OK
434
434
435
- s = '' # type: str
436
- s = a # OK
435
+ s = '' # Inferred type of 's' is str
436
+ s = a # OK
437
437
438
438
def foo(item: Any) -> int:
439
439
# Typechecks; 'item' could be any type,
@@ -1779,11 +1779,10 @@ Asynchronous programming
1779
1779
correspond to those of :class: `Generator `, for example::
1780
1780
1781
1781
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]
1785
1784
async def bar() -> None:
1786
- x = await c # type: int
1785
+ y = await c # Inferred type of 'y' is int
1787
1786
1788
1787
.. versionadded :: 3.5.3
1789
1788
You can’t perform that action at this time.
0 commit comments