@@ -21,16 +21,53 @@ async def f() -> int:
21
21
return x
22
22
[builtins fixtures/async_await.py]
23
23
24
- [case testAwaitGenerator ]
24
+ [case testAwaitDefaultContext ]
25
25
# options: fast_parser
26
- from typing import Any, Generator
27
- def g() -> Generator[int, int, int]:
28
- x = yield 0
29
- return x
26
+ from typing import Any, TypeVar
27
+ T = TypeVar('T')
28
+ async def f(x: T) -> T:
29
+ y = await f(x)
30
+ reveal_type(y)
31
+ return y
32
+ [out]
33
+ main: note: In function "f":
34
+ main:6: error: Revealed type is 'T`-1'
35
+
36
+ [case testAwaitAnyContext]
37
+ # options: fast_parser
38
+ from typing import Any, TypeVar
39
+ T = TypeVar('T')
40
+ async def f(x: T) -> T:
41
+ y = await f(x) # type: Any
42
+ reveal_type(y)
43
+ return y
44
+ [out]
45
+ main: note: In function "f":
46
+ main:6: error: Revealed type is 'Any'
47
+
48
+ [case testAwaitExplicitContext]
49
+ # options: fast_parser
50
+ from typing import Any, TypeVar
51
+ T = TypeVar('T')
52
+ async def f(x: T) -> T:
53
+ y = await f(x) # type: int
54
+ reveal_type(y)
55
+ [out]
56
+ main: note: In function "f":
57
+ main:5: error: Argument 1 to "f" has incompatible type "T"; expected "int"
58
+ main:6: error: Revealed type is 'builtins.int'
59
+
60
+ [case testAwaitGeneratorError]
61
+ # options: fast_parser
62
+ from typing import Any, Iterator
63
+ def g() -> Iterator[Any]:
64
+ yield
30
65
async def f() -> int:
31
66
x = await g()
32
67
return x
33
- [builtins fixtures/async_await.py]
68
+ [out]
69
+ main: note: In function "f":
70
+ main: error: Incompatible types in await (actual type Iterator[Any], expected Awaitable)
34
71
35
72
[case testAwaitArgumentError]
36
73
# options: fast_parser
@@ -42,7 +79,7 @@ async def f() -> int:
42
79
[builtins fixtures/async_await.py]
43
80
[out]
44
81
main: note: In function "f":
45
- main: error: Incompatible types in await (actual type "int", expected Awaitable or Generator )
82
+ main: error: Incompatible types in await (actual type "int", expected Awaitable)
46
83
47
84
[case testAwaitResultError]
48
85
# options: fast_parser
0 commit comments