-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly
Description
Bug Report
mypy doesn't allow empty yield statements in generator functions that accept send() values
To Reproduce
from typing import Any, Generator
def foo() -> Generator[int, Any, None]:
yield
while True:
yield 42Expected Behavior
I expected the second parameter (Any) in Generator[int, Any, None] to indicate that this generator accepts a send() value and that therefore the naked yield statement is accepting a value but not sending one. As far as I know the above code is idiomatic.
Actual Behavior
error: Yield value expected
mypy complains that a yield value is expected, but this standalone yield is for the purpose of accepting the value of a send() to the generator.
Your Environment
mypy 0.812
python 3.7
JSS95, martjushev, jheiss, Kentzo, onnodb and 4 moredimaqq
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly