Skip to content

Commit 02aa0c3

Browse files
committed
Update error message
1 parent 2549b48 commit 02aa0c3

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

docs/source/error_code_list2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ Example:
282282
# - the expected error 'assignment', and
283283
# - the unexpected error 'attr-defined'
284284
# are silenced.
285-
# Error: "type: ignore" comment without error code (currently ignored: [attr-defined])
285+
# Error: "type: ignore" comment without error code (use "type: ignore[attr-defined]" instead)
286286
f.nme = 42 # type: ignore
287287
288288
# This line warns correctly about the typo in the attribute name

mypy/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ def generate_ignore_without_code_errors(self,
534534
codes_hint = ''
535535
ignored_codes = sorted(set(used_ignored_lines[line]))
536536
if ignored_codes:
537-
codes_hint = f' (currently ignored: [{", ".join(ignored_codes)}])'
537+
codes_hint = f' (use "type: ignore[{", ".join(ignored_codes)}]" instead)'
538538

539539
message = f'"type: ignore" comment without error code{codes_hint}'
540540
# Don't use report since add_error_info will ignore the error!

test-data/unit/check-errorcodes.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ x # type: ignore[name-defined, attr-defined] # E: Unused "type: ignore[attr-defi
148148
[case testErrorCodeMissingWhenRequired]
149149
# flags: --enable-error-code ignore-without-code
150150
"x" # type: ignore # E: "type: ignore" comment without error code [ignore-without-code]
151-
y # type: ignore # E: "type: ignore" comment without error code (currently ignored: [name-defined]) [ignore-without-code]
151+
y # type: ignore # E: "type: ignore" comment without error code (use "type: ignore[name-defined]" instead) [ignore-without-code]
152152
z # type: ignore[name-defined]
153153
"a" # type: ignore[ignore-without-code]
154154

@@ -173,7 +173,7 @@ class A:
173173

174174
a: A | None
175175
# 'union-attr' should only be listed once (instead of twice) and list should be sorted
176-
a.func("invalid string").attr # type: ignore # E: "type: ignore" comment without error code (currently ignored: [arg-type, union-attr]) [ignore-without-code]
176+
a.func("invalid string").attr # type: ignore # E: "type: ignore" comment without error code (use "type: ignore[arg-type, union-attr]" instead) [ignore-without-code]
177177
[builtins fixtures/tuple.pyi]
178178

179179
[case testErrorCodeIgnoreWithExtraSpace]

0 commit comments

Comments
 (0)