"Yield value expected" on generator using send()
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 54
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された Python の例を mypy で実行し、「Yield value expected」診断を確認します。mypy がジェネレーターの yield 文と Generator の send 型をどのようにチェックするかを追跡します。この場合に単独の yield が受け入れられ、例に対するリグレッションカバレッジが追加されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100