False positive: Callable arg types more strict than required
オープン
まだ誰も着手していません。
bug
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Struggled to name this properly but here's a repro:
import typing
# Want to accept any callable with a string arg
CallableT = typing.Callable[[str], None]
def func(callable_m: dict[str, CallableT]) -> None:
callable_m['first']("a")
def first(a: str) -> None:
return None
def second(a: str) -> None:
return None
def third(b: str) -> None:
return None
# This mapping will fail because the callables will have type:
# Callable[[Arg(str, 'a')], None]
failed_mapping = {
'first': first,
'second': second
}
func(failed_mapping)
# By renaming the arg in `third` from `a` to `b` everything is groovy
passing_mapping = {
'first': first,
'third': third
}
func(passing_mapping)
https://mypy-play.net/?mypy=latest&python=3.11&gist=ff039c923e370f79a680c463ef627810
Easy workaround with renaming the arg but is a bit of a pain
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供されている Python の再現コードと mypy-play リンクから始め、次にパラメーター名を比較する callable 互換性チェックを追跡します。焦点を絞った回帰テストで動作を確認します。first や second のような互換性のある callable が、パラメーター名を変更せずに受け入れられれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100