Type application is only supported for generic classes
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
To Reproduce
from typing import Any, TYPE_CHECKING
if TYPE_CHECKING:
from typing import Union, TypeVar
T = TypeVar('T')
WithProtocols = Union[T, T] # noqa: UP007,PYI016
else:
class WithProtocols:
def __class_getitem__(cls, item: Any) -> Any:
return item
WithProtocols[int]
Expected Behavior
I expected mypy not to swear
Actual behavior
error: Type application is only supported for generic classes [misc]
My environment
mypy == 3.11.1
python == 3.11.8
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.
Research direction
Run the supplied Python 3.11 reproducer and trace the type-application diagnostic through mypy's type-checking path. Done means this case no longer emits the [misc] error, with regression coverage for the reproducer.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100