Warn if generator is iterated over more than once
オープン
まだ誰も着手していません。
feature
priority-2-low
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Somewhat related to #4707
This code currently does not give any warnings:
gen = (3 * x for x in range(10)) # revealed type: Generator[int, None, None]
for i in gen:
print(i)
for i in gen:
print(i)
and while this does run, it doesn't do what the programmer expects. Only the first iteration prints anything. The second iteration stops immediately because the generator is already exhausted.
This might be very difficult, but it would be nice if mypy could detect this.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
issue の generator の例から始め、同じ generator が複数回イテレーションされていることを mypy がどのように識別できるかを調査します。2 回目のイテレーションに対して警告を出しつつ、generator の有効な使用には警告を出さなければ完了です。issue にはファイルやテストの指定がないため、まず実装と回帰テストに関連する場所を特定する必要があります。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100