@@ -1231,6 +1231,9 @@ def h1():
12311231def h2():
12321232 yield
12331233 return "abc"
1234+ def h3():
1235+ yield
1236+ return None
12341237def all():
12351238 x = yield 123
12361239 return "abc"
@@ -1242,6 +1245,7 @@ def f() -> Generator[Incomplete, None, None]: ...
12421245def g() -> Generator[None, Incomplete, None]: ...
12431246def h1() -> Generator[None, None, None]: ...
12441247def h2() -> Generator[None, None, Incomplete]: ...
1248+ def h3() -> Generator[None, None, None]: ...
12451249def all() -> Generator[Incomplete, Incomplete, Incomplete]: ...
12461250
12471251[case testFunctionYieldsNone]
@@ -1270,6 +1274,69 @@ class Generator: ...
12701274
12711275def f() -> _Generator[Incomplete, None, None]: ...
12721276
1277+ [case testGeneratorYieldFrom]
1278+ def g1():
1279+ yield from x
1280+ def g2():
1281+ y = yield from x
1282+ def g3():
1283+ yield from x
1284+ return
1285+ def g4():
1286+ yield from x
1287+ return None
1288+ def g5():
1289+ yield from x
1290+ return z
1291+
1292+ [out]
1293+ from _typeshed import Incomplete
1294+ from collections.abc import Generator
1295+
1296+ def g1() -> Generator[Incomplete, Incomplete, None]: ...
1297+ def g2() -> Generator[Incomplete, Incomplete, None]: ...
1298+ def g3() -> Generator[Incomplete, Incomplete, None]: ...
1299+ def g4() -> Generator[Incomplete, Incomplete, None]: ...
1300+ def g5() -> Generator[Incomplete, Incomplete, Incomplete]: ...
1301+
1302+ [case testGeneratorYieldAndYieldFrom]
1303+ def g1():
1304+ yield x1
1305+ yield from x2
1306+ def g2():
1307+ yield x1
1308+ y = yield from x2
1309+ def g3():
1310+ y = yield x1
1311+ yield from x2
1312+ def g4():
1313+ yield x1
1314+ yield from x2
1315+ return
1316+ def g5():
1317+ yield x1
1318+ yield from x2
1319+ return None
1320+ def g6():
1321+ yield x1
1322+ yield from x2
1323+ return z
1324+ def g7():
1325+ yield None
1326+ yield from x2
1327+
1328+ [out]
1329+ from _typeshed import Incomplete
1330+ from collections.abc import Generator
1331+
1332+ def g1() -> Generator[Incomplete, Incomplete, None]: ...
1333+ def g2() -> Generator[Incomplete, Incomplete, None]: ...
1334+ def g3() -> Generator[Incomplete, Incomplete, None]: ...
1335+ def g4() -> Generator[Incomplete, Incomplete, None]: ...
1336+ def g5() -> Generator[Incomplete, Incomplete, None]: ...
1337+ def g6() -> Generator[Incomplete, Incomplete, Incomplete]: ...
1338+ def g7() -> Generator[Incomplete, Incomplete, None]: ...
1339+
12731340[case testCallable]
12741341from typing import Callable
12751342
@@ -2977,13 +3044,17 @@ def func(*, non_default_kwarg: bool, default_kwarg: bool = True): ...
29773044def func(*, non_default_kwarg: bool, default_kwarg: bool = ...): ...
29783045
29793046[case testNestedGenerator]
2980- def f ():
3047+ def f1 ():
29813048 def g():
29823049 yield 0
2983-
3050+ return 0
3051+ def f2():
3052+ def g():
3053+ yield from [0]
29843054 return 0
29853055[out]
2986- def f(): ...
3056+ def f1(): ...
3057+ def f2(): ...
29873058
29883059[case testKnownMagicMethodsReturnTypes]
29893060class Some:
@@ -3193,6 +3264,10 @@ def gen():
31933264 y = yield x
31943265 return z
31953266
3267+ def gen2():
3268+ y = yield from x
3269+ return z
3270+
31963271class X(unknown_call("X", "a b")): ...
31973272class Y(collections.namedtuple("Y", xx)): ...
31983273[out]
@@ -3227,6 +3302,7 @@ TD2: _Incomplete
32273302TD3: _Incomplete
32283303
32293304def gen() -> _Generator[_Incomplete, _Incomplete, _Incomplete]: ...
3305+ def gen2() -> _Generator[_Incomplete, _Incomplete, _Incomplete]: ...
32303306
32313307class X(_Incomplete): ...
32323308class Y(_Incomplete): ...
0 commit comments