Passing `**dict(...)` to `functools.partial` confuses mypy
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Bug Report
Something like partial(func, **dict(a=1)) confuses mypy which seems to expect the dictionary keys to contain all the arguments to func, leading to errors if positional arguments are not specified (see this playground / gist), or if only a few arguments are specified and later more as passed to partial's return value (see this playground / gist).
Expected Behavior
I realise that mypy cannot know what ends up in an untyped dictionary, but it should maybe just give up in this case.
Actual Behavior
See gist.
Your Environment
- Mypy version used:
mypy 1.15.0 (compiled: yes), but alsomasterwhile using the playground - Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.10.1, but also 3.13 while using the playground
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、リンク先の mypy playground と gist にある2つの例を、mypy 1.15.0 と master で再現します。functools.partial がアンパックされた辞書をどのように処理するかを追跡し、その後、報告されたケースで誤った診断が生成されなくなっている一方で、有効な partial 呼び出しは引き続きチェックされることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100