Incorrect send type with `yield from`
オープン
まだ誰も着手していません。
bug
topic-runtime-semantics
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Bug Report
Generators do not respect the send type when using yield from.
To Reproduce
def foo() -> Generator[None, int, None]:
x: int = yield
def bar() -> Generator[None, str, None]:
yield from foo()
Expected Behavior
Should error on yield from foo().
Actual Behavior
Does not error and allows gen = bar(); gen.send("abc"), which results in x: int = "abc".
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず issue 内の Python 再現コードを実行し、mypy が yield from を通じてジェネレーターの send 型をどのようにチェックしているかを追跡します。foo() と bar() を対象とする回帰テストを追加し、mypy が文字列を整数型のジェネレーターに送ることを許可するのではなく、yield from foo() でエラーを報告することを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100