python / python/mypy

mypy doesn't get error with typed `dict(*{'A': 10})` while PVM gets error

オープン
#20,702 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug topic-type-context
主要言語
Python
スター
20.6k
フォーク
3.3k
PR マージ指標
PR 指標を取得中

説明

*Memo:

  • python test.py
  • mypy test.py
  • Python 3.14.0
  • mypy 1.19.1

PVM gets the error with typed and untyped dict(*{'A': 10}) as shown below:

v1 = dict(*{'A': 10})                 # Error
v2: dict[str, int] = dict(*{'A': 10}) # Error

ValueError: dictionary update sequence element #0 has length 1; 2 is required

But, mypy gets the error only for untyped dict(*{'A': 10}) while typed dict(*{'A': 10}) doesn't get error as shown below:

v1 = dict(*{'A': 10})                 # Error
v2: dict[str, int] = dict(*{'A': 10}) # No error

error: Need type annotation for "v1" (hint: "v1: dict[, ] = ...")

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、Python 3.14.0 と mypy 1.19.1 で test.py の例を再現し、型付きと型なしの dict(*{'A': 10}) のケースを比較します。注釈付き代入の型チェック経路を追跡し、実行時に無効な呼び出しに対して期待される診断を記録する回帰テストを追加します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
devtools
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。