Skip to content

Commit 63ca2a1

Browse files
committed
Add missing lineno
1 parent 905ea7b commit 63ca2a1

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

mypy/checkexpr.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6141,6 +6141,7 @@ def visit_yield_from_expr(self, e: YieldFromExpr, allow_none_return: bool = Fals
61416141
generic_generator_type = self.chk.named_generic_type(
61426142
"typing.Generator", [any_type, any_type, any_type]
61436143
)
6144+
generic_generator_type.set_line(e)
61446145
iter_type, _ = self.check_method_call_by_name(
61456146
"__iter__", subexpr_type, [], [], context=generic_generator_type
61466147
)

test-data/unit/check-statements.test

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2283,6 +2283,19 @@ def get_strings(foo: bool) -> Iterator[str]:
22832283
yield "bar2"
22842284
[builtins fixtures/tuple.pyi]
22852285

2286+
[case testYieldFromInvalidType]
2287+
from collections.abc import Iterator
2288+
2289+
class A:
2290+
def list(self) -> None: ...
2291+
2292+
def foo(self) -> list[int]:
2293+
return []
2294+
2295+
def fn() -> Iterator[int]:
2296+
yield from A().foo()
2297+
[builtins fixtures/tuple.pyi]
2298+
22862299
[case testNoCrashOnStarRightHandSide]
22872300
x = *(1, 2, 3) # E: can't use starred expression here
22882301
[builtins fixtures/tuple.pyi]

0 commit comments

Comments
 (0)