python / python/mypy

Using type application with a function call gets a wrong error message

Open
#20,927 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-error-reporting
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

*Notes:

  • mypy test.py
  • mypy 1.19.1
  • Python 3.14.0

Using type application with a function call gets the error message as shown below:

def func[T](x: T) -> T:
    return x

func[int](100) # Error

error: Type application is only supported for generic classes

But type application is also supported for generic type aliases as shown below:

type TA[T] = list[T]

v: TA[int] # No error

So the error message should be as shown below:

error: Type application is only supported for generic classes and type aliases

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

Reproduce the report with the generic function and type-alias examples in test.py by running mypy test.py. Find the diagnostic that reports type applications as supported only for generic classes, then update its wording to include type aliases and add regression coverage showing the expected message.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.