Standalone subscripted alias expression fails mypy check
@sobolevn is already working on this.
Since Aug 11, 2022.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
Standalone subscripted alias expression raises the error "Type application is only supported for generic classes"
To Reproduce
Here's a reproducible playground link: https://mypy-play.net/?mypy=0.971&python=3.10&gist=e262d3dd99f2a708e96eb28338792632
Code:
T = TypeVar("T")
OptionalT: TypeAlias = Optional[T]
OptionalT[int] # error: Type application is only supported for generic classes
Expected Behavior
I was surprised that you couldn't have a free expression of the subscripted generic type alias. Standalone expressions like Optional[int] obviously work, as does X where X: TypeAlias = int.
Actual Behavior
The free expression gives the error: Type application is only supported for generic classes in the playground
Your Environment
The environment is python 3.10, mypy 0.971.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.