Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitebf40a5

Browse files
committed
additional tests
1 parent1082552 commitebf40a5

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

‎test-data/unit/check-warnings.test‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
7677
a = 1
7778
b: 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]
8993
main: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
93109
from dataclasses import dataclass

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp