"Yield value expected" on generator using send()
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 42
Expected 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
Still a problem in 0.982
Also an issue for AsyncGenerator[…, …] in v1.1.1.
Just ran into this myself. This is not resolved at this time, correct?