python / python/mypy

Using a type alias with arguments in `case` block in a `match` statement gets the wrong error message with `parameters` instead of `arguments`

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

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

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

説明

*Memo:

  • mypy test.py
  • mypy 1.19.1
  • Python 3.14
  • Windows 11

Using a type alias with arguments in case block in a match statement gets the wrong error message with parameters instead of arguments as shown below:

class Cls:
    def __init__(self, x: int, y: int):
        self.x = x
        self.y = y

type TA = Cls

match Cls(x=10, y=20):
    case TA(x=10, y=20):
        print("OK")

error: Class pattern class must not be a type alias with type parameters

So, the error message should be with arguments instead of parameters as shown below:

error: Class pattern class must not be a type alias with type arguments

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

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

はじめの一歩

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

調査の方向性

まず、mypy 1.19.1 と Python 3.14 を使って mypy test.py で報告を再現し、次にクラスパターンで使用されている型エイリアスに対する診断を特定します。“type parameters” から “type arguments” へ文言を更新し、例で修正後のメッセージが報告されることを確認します。

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

評価

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

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

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