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`

Aperta
#20,495 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug topic-match-statement
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

*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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo il report con mypy test.py usando mypy 1.19.1 e Python 3.14, quindi individua la diagnostica per un alias di tipo usato in un pattern di classe. Aggiorna la formulazione da “type parameters” a “type arguments” e verifica che l’esempio riporti il messaggio corretto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
compilers
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.