Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
additional tests
  • Loading branch information
grayjk committed Nov 16, 2025
commit ebf40a5b05ef15bb29d2ccd6c371d5e815fc6180
18 changes: 17 additions & 1 deletion test-data/unit/check-warnings.test
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,14 @@ def f(q: Union[x, y, z]) -> None:

[case testRedundantAnnotation]
# flags: --warn-redundant-annotation
from typing import Literal
a = 1
b: int = a
c: Literal[1] = 1
d: list[str] = []
[out]
main:3: error: Annotation "int" is redundant (inferred type is the same)
main:4: error: Annotation "int" is redundant (inferred type is the same)
main:5: error: Annotation "Literal[1]" is redundant (inferred type is the same)

[case testRedundantAnnotationClassVar]
# flags: --warn-redundant-annotation
Expand All @@ -88,6 +92,18 @@ class a:
[out]
main:5: error: Annotation "int" is redundant (inferred type is the same)

[case testRedundantAnnotationTypeVar]
# flags: --warn-redundant-annotation
from typing import Literal, TypeVar

T = TypeVar("T")

def f(x: T) -> T:
return x

x: Literal[1] = f(1)
y: list[str] = f([])

[case testRedundantAnnotationSkips]
# flags: --warn-redundant-annotation
from dataclasses import dataclass
Expand Down