Skip to content

Commit 15fbd53

Browse files
eevelweezeleevel
and
eevel
authored
Add tests for language changes in 3.11 (#15120)
Fixes #15111 Adds tests for: - AsyncGenerator within an AsyncGenerator - Unpacking iterables in a for loop using star syntax Co-authored-by: eevel <eevel@weezel3.weezelnet>
1 parent 334daca commit 15fbd53

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

test-data/unit/check-python311.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,17 @@ class Variadic(Generic[Unpack[Ts]]):
6363
variadic: Variadic[int, str]
6464
reveal_type(variadic) # N: Revealed type is "__main__.Variadic[builtins.int, builtins.str]"
6565
[builtins fixtures/tuple.pyi]
66+
67+
[case testAsyncGeneratorWithinComprehension]
68+
# flags: --python-version 3.11
69+
from typing import Any, Generator, List
70+
71+
async def asynciter(iterable):
72+
for x in iterable:
73+
yield x
74+
75+
async def coro() -> Generator[List[Any], None, None]:
76+
return ([i async for i in asynciter([0,j])] for j in [3, 5])
77+
reveal_type(coro) # N: Revealed type is "def () -> typing.Coroutine[Any, Any, typing.Generator[builtins.list[Any], None, None]]"
78+
[builtins fixtures/async_await.pyi]
79+
[typing fixtures/typing-async.pyi]

test-data/unit/check-python39.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,12 @@ decorator_list: List[Callable[..., Callable[[int], str]]]
1717
def f(x: float) -> float: ...
1818
reveal_type(f) # N: Revealed type is "def (builtins.int) -> builtins.str"
1919
[builtins fixtures/list.pyi]
20+
21+
[case testStarredExpressionsInForLoop]
22+
# flags: --python-version 3.9
23+
24+
a = b = c = [1, 2, 3]
25+
for x in *a, *b, *c:
26+
reveal_type(x) # N: Revealed type is "builtins.int"
27+
[builtins fixtures/tuple.pyi]
28+

0 commit comments

Comments
 (0)