Skip to content

Commit

Permalink
Tweak ignore-without-code error message (#12216)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p authored Feb 19, 2022
1 parent 85fc99c commit 36d50d6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/source/error_code_list2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ Example:
# - the expected error 'assignment', and
# - the unexpected error 'attr-defined'
# are silenced.
# Error: "type: ignore" comment without error code (use "type: ignore[attr-defined]" instead)
# Error: "type: ignore" comment without error code (consider "type: ignore[attr-defined]" instead)
f.nme = 42 # type: ignore
# This line warns correctly about the typo in the attribute name
Expand Down
2 changes: 1 addition & 1 deletion mypy/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def generate_ignore_without_code_errors(self,
codes_hint = ''
ignored_codes = sorted(set(used_ignored_lines[line]))
if ignored_codes:
codes_hint = f' (use "type: ignore[{", ".join(ignored_codes)}]" instead)'
codes_hint = f' (consider "type: ignore[{", ".join(ignored_codes)}]" instead)'

message = f'"type: ignore" comment without error code{codes_hint}'
# Don't use report since add_error_info will ignore the error!
Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/check-errorcodes.test
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ x # type: ignore[name-defined, attr-defined] # E: Unused "type: ignore[attr-defi
[case testErrorCodeMissingWhenRequired]
# flags: --enable-error-code ignore-without-code
"x" # type: ignore # E: "type: ignore" comment without error code [ignore-without-code]
y # type: ignore # E: "type: ignore" comment without error code (use "type: ignore[name-defined]" instead) [ignore-without-code]
y # type: ignore # E: "type: ignore" comment without error code (consider "type: ignore[name-defined]" instead) [ignore-without-code]
z # type: ignore[name-defined]
"a" # type: ignore[ignore-without-code]

Expand All @@ -173,7 +173,7 @@ class A:

a: A | None
# 'union-attr' should only be listed once (instead of twice) and list should be sorted
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]
a.func("invalid string").attr # type: ignore # E: "type: ignore" comment without error code (consider "type: ignore[arg-type, union-attr]" instead) [ignore-without-code]
[builtins fixtures/tuple.pyi]

[case testErrorCodeIgnoreWithExtraSpace]
Expand Down

0 comments on commit 36d50d6

Please sign in to comment.