-
Notifications
You must be signed in to change notification settings - Fork 182
Closed
Labels
Description
Describe the Bug
Minimal repro:
from typing import Annotated
A = Annotated
def test(x: A[int, 0]) -> None:
passExpected: No type error
Actual:
- Expected a type argument for
Annotated type[Annotated]is not subscriptable
In practice people probably won't do this kind of trivial aliasing within the same file. What would happen instead is that they tend to do it in version-compatibility shims, e.g.
# my_library.py
import sys
import typing
if sys.version_info < (3, 9):
Annotated = SOME_CUSTOM_IMPLEMENTATION_OF_ANNOTATED
else:
Annotated = typing.Annotated
# my_app.py
from my_library import Annotated
def test(x: Annotated[int, 0]) -> None:
passThe pattern is currently (as of 11/14/2025) recognized by both Pyright and Ty, but not Mypy.
Sandbox Link
(Only applicable for extension issues) IDE Information
No response