@@ -73,10 +73,14 @@ def f(q: Union[x, y, z]) -> None:
7373
7474[case testRedundantAnnotation]
7575# flags: --warn-redundant-annotation
76+ from typing import Literal
7677a = 1
7778b: int = a
79+ c: Literal[1] = 1
80+ d: list[str] = []
7881[out]
79- main:3: error: Annotation "int" is redundant (inferred type is the same)
82+ main:4: error: Annotation "int" is redundant (inferred type is the same)
83+ main:5: error: Annotation "Literal[1]" is redundant (inferred type is the same)
8084
8185[case testRedundantAnnotationClassVar]
8286# flags: --warn-redundant-annotation
@@ -88,6 +92,18 @@ class a:
8892[out]
8993main:5: error: Annotation "int" is redundant (inferred type is the same)
9094
95+ [case testRedundantAnnotationTypeVar]
96+ # flags: --warn-redundant-annotation
97+ from typing import Literal, TypeVar
98+
99+ T = TypeVar("T")
100+
101+ def f(x: T) -> T:
102+ return x
103+
104+ x: Literal[1] = f(1)
105+ y: list[str] = f([])
106+
91107[case testRedundantAnnotationSkips]
92108# flags: --warn-redundant-annotation
93109from dataclasses import dataclass