Skip to content

Commit 50db29a

Browse files
authored
Capitalize unused type ignore message, for consistency (#11569)
1 parent f994bfe commit 50db29a

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

mypy/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ def generate_unused_ignore_errors(self, file: str) -> None:
478478
unused_codes_message = ""
479479
if len(ignored_codes) > 1 and len(unused_ignored_codes) > 0:
480480
unused_codes_message = f"[{', '.join(sorted(unused_ignored_codes))}]"
481-
message = f'unused "type: ignore{unused_codes_message}" comment'
481+
message = f'Unused "type: ignore{unused_codes_message}" comment'
482482
# Don't use report since add_error_info will ignore the error!
483483
info = ErrorInfo(self.import_context(), file, self.current_module(), None,
484484
None, line, -1, 'error', message,

test-data/unit/check-errorcodes.test

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,27 +113,27 @@ b = 'x'.foobar(b) # type: int # type: ignore[name-defined, xyz] # E: "str" has
113113

114114
[case testErrorCodeWarnUnusedIgnores1]
115115
# flags: --warn-unused-ignores
116-
x # type: ignore[name-defined, attr-defined] # E: unused "type: ignore[attr-defined]" comment
116+
x # type: ignore[name-defined, attr-defined] # E: Unused "type: ignore[attr-defined]" comment
117117

118118
[case testErrorCodeWarnUnusedIgnores2]
119119
# flags: --warn-unused-ignores
120120
"x".foobar(y) # type: ignore[name-defined, attr-defined]
121121

122122
[case testErrorCodeWarnUnusedIgnores3]
123123
# flags: --warn-unused-ignores
124-
"x".foobar(y) # type: ignore[name-defined, attr-defined, xyz] # E: unused "type: ignore[xyz]" comment
124+
"x".foobar(y) # type: ignore[name-defined, attr-defined, xyz] # E: Unused "type: ignore[xyz]" comment
125125

126126
[case testErrorCodeWarnUnusedIgnores4]
127127
# flags: --warn-unused-ignores
128-
"x".foobar(y) # type: ignore[name-defined, attr-defined, valid-type] # E: unused "type: ignore[valid-type]" comment
128+
"x".foobar(y) # type: ignore[name-defined, attr-defined, valid-type] # E: Unused "type: ignore[valid-type]" comment
129129

130130
[case testErrorCodeWarnUnusedIgnores5]
131131
# flags: --warn-unused-ignores
132-
"x".foobar(y) # type: ignore[name-defined, attr-defined, valid-type, xyz] # E: unused "type: ignore[valid-type, xyz]" comment
132+
"x".foobar(y) # type: ignore[name-defined, attr-defined, valid-type, xyz] # E: Unused "type: ignore[valid-type, xyz]" comment
133133

134134
[case testErrorCodeWarnUnusedIgnores6_NoDetailWhenSingleErrorCode]
135135
# flags: --warn-unused-ignores
136-
"x" # type: ignore[name-defined] # E: unused "type: ignore" comment
136+
"x" # type: ignore[name-defined] # E: Unused "type: ignore" comment
137137

138138
[case testErrorCodeIgnoreWithExtraSpace]
139139
x # type: ignore [name-defined]

test-data/unit/check-ignore.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ yield # type: ignore # E: "yield" outside function
222222
[case testIgnoreWholeModule1]
223223
# flags: --warn-unused-ignores
224224
# type: ignore
225-
IGNORE # type: ignore # E: unused "type: ignore" comment
225+
IGNORE # type: ignore # E: Unused "type: ignore" comment
226226

227227
[case testIgnoreWholeModule2]
228228
# type: ignore

test-data/unit/check-incremental.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3671,7 +3671,7 @@ pass
36713671
[out]
36723672
[out2]
36733673
[out3]
3674-
tmp/a.py:2: error: unused "type: ignore" comment
3674+
tmp/a.py:2: error: Unused "type: ignore" comment
36753675

36763676
-- Test that a non cache_fine_grained run can use a fine-grained cache
36773677
[case testRegularUsesFgCache]

test-data/unit/check-python38.test

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def f(): ... # E: Function is missing a return type annotation \
1818
def d(f): ... # type: ignore
1919
@d
2020
# type: ignore
21-
def f(): ... # type: ignore # E: unused "type: ignore" comment
21+
def f(): ... # type: ignore # E: Unused "type: ignore" comment
2222

2323
[case testIgnoreDecoratedFunction2]
2424
# flags: --disallow-untyped-defs
@@ -91,28 +91,28 @@ def g(x: int): ...
9191

9292
[case testIgnoreScopeUnused1]
9393
# flags: --warn-unused-ignores
94-
( # type: ignore # E: unused "type: ignore" comment
95-
"IGNORE" # type: ignore # E: unused "type: ignore" comment
96-
+ # type: ignore # E: unused "type: ignore" comment
94+
( # type: ignore # E: Unused "type: ignore" comment
95+
"IGNORE" # type: ignore # E: Unused "type: ignore" comment
96+
+ # type: ignore # E: Unused "type: ignore" comment
9797
0 # type: ignore
98-
) # type: ignore # E: unused "type: ignore" comment
98+
) # type: ignore # E: Unused "type: ignore" comment
9999
[builtins fixtures/primitives.pyi]
100100

101101
[case testIgnoreScopeUnused2]
102102
# flags: --warn-unused-ignores
103-
( # type: ignore # E: unused "type: ignore" comment
103+
( # type: ignore # E: Unused "type: ignore" comment
104104
"IGNORE"
105105
- # type: ignore
106-
0 # type: ignore # E: unused "type: ignore" comment
107-
) # type: ignore # E: unused "type: ignore" comment
106+
0 # type: ignore # E: Unused "type: ignore" comment
107+
) # type: ignore # E: Unused "type: ignore" comment
108108

109109
[case testIgnoreScopeUnused3]
110110
# flags: --warn-unused-ignores
111-
( # type: ignore # E: unused "type: ignore" comment
111+
( # type: ignore # E: Unused "type: ignore" comment
112112
"IGNORE"
113113
/
114114
0 # type: ignore
115-
) # type: ignore # E: unused "type: ignore" comment
115+
) # type: ignore # E: Unused "type: ignore" comment
116116

117117
[case testPEP570ArgTypesMissing]
118118
# flags: --disallow-untyped-defs

test-data/unit/check-warnings.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ a = 1
5151
if int():
5252
a = 'a' # type: ignore
5353
if int():
54-
a = 2 # type: ignore # E: unused "type: ignore" comment
54+
a = 2 # type: ignore # E: Unused "type: ignore" comment
5555
if int():
5656
a = 'b' # E: Incompatible types in assignment (expression has type "str", variable has type "int")
5757

@@ -63,8 +63,8 @@ from m import * # type: ignore
6363
[file m.py]
6464
pass
6565
[out]
66-
main:3: error: unused "type: ignore" comment
67-
main:4: error: unused "type: ignore" comment
66+
main:3: error: Unused "type: ignore" comment
67+
main:4: error: Unused "type: ignore" comment
6868

6969

7070
-- No return

0 commit comments

Comments
 (0)