File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -907,3 +907,32 @@ def test_same_names() -> None:
907907 # matches the variable name in the input code, since internally it's generated
908908 # with a prefix.
909909 list(undefined())
910+
911+ [case testGeneratorInheritance]
912+ from typing import Iterator
913+
914+ class Base1:
915+ def foo(self) -> Iterator[int]:
916+ yield 1
917+
918+ class Derived1(Base1):
919+ def foo(self) -> Iterator[int]:
920+ yield 2
921+ yield 3
922+
923+ def base1_foo(b: Base1) -> list[int]:
924+ a = []
925+ for x in b.foo():
926+ a.append(x)
927+ return a
928+
929+ def derived1_foo(b: Derived1) -> list[int]:
930+ a = []
931+ for x in b.foo():
932+ a.append(x)
933+ return a
934+
935+ def test_generator_override() -> None:
936+ assert base1_foo(Base1()) == [1]
937+ assert base1_foo(Derived1()) == [2, 3]
938+ assert derived1_foo(Derived1()) == [2, 3]
You can’t perform that action at this time.
0 commit comments