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`

Open
#20,495 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-match-statement
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

*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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the report with mypy test.py using mypy 1.19.1 and Python 3.14, then locate the diagnostic for a type alias used in a class pattern. Update the wording from “type parameters” to “type arguments” and verify that the example reports the corrected message.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.