Assigning an iterator to the type hint `collections.abc.Hashable` gets error even though an iterator is hashable
オープン
まだ誰も着手していません。
bug
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 54
説明
*Memo:
- Python 3.14.0
- mypy 1.18.2
- mypy test.py
- Windows 11
An iterator is hashable as shown below:
print(hash(iter([0, 1, 2])))
# 127553071047
But assigning an iterator to the type hint collections.abc.Hashable gets the error as shown below even though an iterator is hashable:
from collections.abc import Hashable
v: Hashable = iter([0, 1, 2])
# Error
error: Incompatible types in assignment (expression has type "Iterator[int]", variable has type "Hashable")
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、Python 3.14.0 と mypy 1.18.2 を使って test.py の課題を再現し、その後、mypy が Iterator[int] と collections.abc.Hashable をどのようにモデル化しているかを追跡します。報告された不一致が解消されるか、その意図された静的な動作が回帰テストによって確立されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 42/100