Wrong typing warning for map. (Argument X to "map" has incompatible type overloaded function)
オープン
まだ誰も着手していません。
performance
priority-1-normal
topic-type-variables
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 54
説明
I write this function to check the rightmost common element of two list.
this is the code.
import itertools
def get_common_index(*names: str) -> int:
"""zip genalogy history name tag."""
return max(
i
for i, x in enumerate(
map(
lambda x: len(set(x)) > 1,
list(reversed(list(itertools.zip_longest(*map(reversed, names), fillvalue="0")))),
)
)
if x
)
print(get_common_index("1110111111", "101101111")
It works fine, and the input types are correct.
$ python test.py
5
But mypy raise the following error message.
$ mypy test.py
test.py:24: error: Argument 1 to "map" has incompatible type overloaded function; expected "Callable[[str], Iterator[_T]]"
Is this an error of mypy?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された test.py の例で報告を再現し、mypy における map、reversed、itertools.zip_longest のオーバーロードの扱いを調べます。map に渡された callable が互換性のない形で推論される理由を追跡し、有効な入力型ではこの警告が生成されなくなったことを示す回帰テストを追加または更新します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100