@@ -647,6 +647,26 @@ def f() -> Iterator[int]:
647
647
[out]
648
648
main: note: In function "f":
649
649
650
+ [case testYieldInFunctionReturningGenerator]
651
+ from typing import Generator
652
+ def f() -> Generator[int, None, None]:
653
+ yield 1
654
+ [builtins fixtures/for.py]
655
+ [out]
656
+
657
+ [case testYieldInFunctionReturningIterable]
658
+ from typing import Iterable
659
+ def f() -> Iterable[int]:
660
+ yield 1
661
+ [builtins fixtures/for.py]
662
+ [out]
663
+
664
+ [case testYieldInFunctionReturningObject]
665
+ def f() -> object:
666
+ yield 1
667
+ [builtins fixtures/for.py]
668
+ [out]
669
+
650
670
[case testYieldInFunctionReturningAny]
651
671
from typing import Any
652
672
def f() -> Any:
@@ -656,7 +676,7 @@ def f() -> Any:
656
676
[case testYieldInFunctionReturningFunction]
657
677
from typing import Callable
658
678
def f() -> Callable[[], None]:
659
- yield object() # E: Iterator function return type expected for "yield"
679
+ yield object() # E: The return type of a generator function should be "Generator" or one of its supertypes
660
680
[out]
661
681
main: note: In function "f":
662
682
@@ -668,7 +688,7 @@ def f():
668
688
[case testWithInvalidInstanceReturnType]
669
689
import typing
670
690
def f() -> int:
671
- yield 1 # E: Iterator function return type expected for "yield"
691
+ yield 1 # E: The return type of a generator function should be "Generator" or one of its supertypes
672
692
[builtins fixtures/for.py]
673
693
[out]
674
694
main: note: In function "f":
0 commit comments