Skip to content

Commit 0060bbf

Browse files
update-data
1 parent 8668104 commit 0060bbf

File tree

1 file changed

+39
-21
lines changed

1 file changed

+39
-21
lines changed

test-data/unit/check-errorcodes.test

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,31 @@ for v in x: # type: int, int # type: ignore[syntax]
6060
[case testErrorCodeIgnore1]
6161
'x'.foobar # type: ignore[attr-defined]
6262
'x'.foobar # type: ignore[xyz] # E: "str" has no attribute "foobar" [attr-defined] \
63-
# N: Error code "attr-defined" not covered by "type: ignore" comment
63+
# N: Error code "attr-defined" not covered by "type: ignore" comment ignoring [xyz]
6464
'x'.foobar # type: ignore
6565

66+
6667
[case testErrorCodeIgnore2]
6768
a = 'x'.foobar # type: int # type: ignore[attr-defined]
6869
b = 'x'.foobar # type: int # type: ignore[xyz] # E: "str" has no attribute "foobar" [attr-defined] \
69-
# N: Error code "attr-defined" not covered by "type: ignore" comment
70+
# N: Error code "attr-defined" not covered by "type: ignore" comment ignoring [xyz]
7071
c = 'x'.foobar # type: int # type: ignore
7172

73+
7274
[case testErrorCodeIgnoreMultiple1]
7375
a = 'x'.foobar(b) # type: ignore[name-defined, attr-defined]
7476
a = 'x'.foobar(b) # type: ignore[name-defined, xyz] # E: "str" has no attribute "foobar" [attr-defined] \
75-
# N: Error code "attr-defined" not covered by "type: ignore" comment
77+
# N: Error code "attr-defined" not covered by "type: ignore" comment ignoring [name-defined, xyz]
7678
a = 'x'.foobar(b) # type: ignore[xyz, w, attr-defined] # E: Name "b" is not defined [name-defined] \
77-
# N: Error code "name-defined" not covered by "type: ignore" comment
79+
# N: Error code "name-defined" not covered by "type: ignore" comment ignoring [xyz, w, attr-defined]
80+
81+
7882

7983
[case testErrorCodeIgnoreMultiple2]
8084
a = 'x'.foobar(c) # type: int # type: ignore[name-defined, attr-defined]
8185
b = 'x'.foobar(c) # type: int # type: ignore[name-defined, xyz] # E: "str" has no attribute "foobar" [attr-defined] \
82-
# N: Error code "attr-defined" not covered by "type: ignore" comment
86+
# N: Error code "attr-defined" not covered by "type: ignore" comment ignoring [name-defined, xyz]
87+
8388

8489
[case testErrorCodeWarnUnusedIgnores1]
8590
# flags: --warn-unused-ignores
@@ -131,7 +136,9 @@ z # type: ignore[name-defined]
131136
"y" # type: ignore[ignore-without-code] # E: Unused "type: ignore" comment [unused-ignore]
132137
z # type: ignore[ignore-without-code] # E: Unused "type: ignore" comment [unused-ignore] \
133138
# E: Name "z" is not defined [name-defined] \
134-
# N: Error code "name-defined" not covered by "type: ignore" comment
139+
# N: Error code "name-defined" not covered by "type: ignore" comment ignoring [ignore-without-code]
140+
141+
135142

136143
[case testErrorCodeMissingWholeFileIgnores]
137144
# flags: --enable-error-code ignore-without-code
@@ -157,21 +164,27 @@ x2 # type: ignore [ name-defined ]
157164
x3 # type: ignore [ xyz , name-defined ]
158165
x4 # type: ignore[xyz,name-defined]
159166
y # type: ignore [xyz] # E: Name "y" is not defined [name-defined] \
160-
# N: Error code "name-defined" not covered by "type: ignore" comment
167+
# N: Error code "name-defined" not covered by "type: ignore" comment ignoring [xyz]
161168
y # type: ignore[ xyz ] # E: Name "y" is not defined [name-defined] \
162-
# N: Error code "name-defined" not covered by "type: ignore" comment
169+
# N: Error code "name-defined" not covered by "type: ignore" comment ignoring [xyz]
163170
y # type: ignore[ xyz , foo ] # E: Name "y" is not defined [name-defined] \
164-
# N: Error code "name-defined" not covered by "type: ignore" comment
171+
# N: Error code "name-defined" not covered by "type: ignore" comment ignoring [xyz, foo]
165172

166173
a = z # type: int # type: ignore [name-defined]
167174
b = z2 # type: int # type: ignore [ name-defined ]
168175
c = z2 # type: int # type: ignore [ name-defined , xyz ]
169176
d = zz # type: int # type: ignore [xyz] # E: Name "zz" is not defined [name-defined] \
170-
# N: Error code "name-defined" not covered by "type: ignore" comment
177+
# N: Error code "name-defined" not covered by "type: ignore" comment ignoring [xyz]
171178
e = zz # type: int # type: ignore [ xyz ] # E: Name "zz" is not defined [name-defined] \
172-
# N: Error code "name-defined" not covered by "type: ignore" comment
179+
# N: Error code "name-defined" not covered by "type: ignore" comment ignoring [xyz]
173180
f = zz # type: int # type: ignore [ xyz,foo ] # E: Name "zz" is not defined [name-defined] \
174-
# N: Error code "name-defined" not covered by "type: ignore" comment
181+
# N: Error code "name-defined" not covered by "type: ignore" comment ignoring [xyz, foo]
182+
183+
184+
185+
186+
187+
175188

176189
[case testErrorCodeIgnoreAfterArgComment]
177190
def f(x # type: xyz # type: ignore[name-defined] # Comment
@@ -185,11 +198,12 @@ def g(x # type: xyz # type: ignore # Comment
185198
pass
186199

187200
def h(x # type: xyz # type: ignore[foo] # E: Name "xyz" is not defined [name-defined] \
188-
# N: Error code "name-defined" not covered by "type: ignore" comment
201+
# N: Error code "name-defined" not covered by "type: ignore" comment ignoring [foo]
189202
):
190203
# type () -> None
191204
pass
192205

206+
193207
[case testErrorCodeIgnoreWithNote]
194208
import nostub # type: ignore[import]
195209
from defusedxml import xyz # type: ignore[import]
@@ -1011,27 +1025,31 @@ class D(TypedDict):
10111025
x: int
10121026

10131027
def f(d: D, s: str) -> None:
1014-
d[s] # type: ignore[xyz] \
1015-
# E: TypedDict key must be a string literal; expected one of ("x") [literal-required] \
1016-
# N: Error code "literal-required" not covered by "type: ignore" comment
1028+
d[s] # type: ignore[xyz] # E: TypedDict key must be a string literal; expected one of ("x") [literal-required] \
1029+
# N: Error code "literal-required" not covered by "type: ignore" comment ignoring [xyz]
10171030
d[s] # E: TypedDict key must be a string literal; expected one of ("x") [literal-required]
1018-
d[s] # type: ignore[misc] \
1019-
# E: TypedDict key must be a string literal; expected one of ("x") [literal-required] \
1020-
# N: Error code changed to literal-required; "type: ignore" comment may be out of date
1031+
d[s] # type: ignore[misc] # E: TypedDict key must be a string literal; expected one of ("x") [literal-required] \
1032+
# N: Error code changed to literal-required; "type: ignore" comment may be out of date
10211033
d[s] # type: ignore[literal-required]
1034+
1035+
1036+
1037+
10221038
[builtins fixtures/dict.pyi]
10231039
[typing fixtures/typing-typeddict.pyi]
10241040

10251041
[case testRecommendErrorCode]
10261042
# type: ignore[whatever] # E: type ignore with error code is not supported for modules; use `# mypy: disable-error-code="whatever"` [syntax] \
1027-
# N: Error code "syntax" not covered by "type: ignore" comment
1043+
# N: Error code "syntax" not covered by "type: ignore" comment ignoring [whatever]
10281044
1 + "asdf"
10291045

1046+
10301047
[case testRecommendErrorCode2]
10311048
# type: ignore[whatever, other] # E: type ignore with error code is not supported for modules; use `# mypy: disable-error-code="whatever, other"` [syntax] \
1032-
# N: Error code "syntax" not covered by "type: ignore" comment
1049+
# N: Error code "syntax" not covered by "type: ignore" comment ignoring [whatever, other]
10331050
1 + "asdf"
10341051

1052+
10351053
[case testShowErrorCodesInConfig]
10361054
# flags: --config-file tmp/mypy.ini
10371055
# Test 'show_error_codes = True' in config doesn't raise an exception

0 commit comments

Comments
 (0)