Skip to content

Commit 765e1c5

Browse files
committed
Rephrase flag to more closely match similar flags
"Disallow" didn't feel right here since mypy was still obeying the ignore comment. "Warn" is more precise since this is configuring a new warning to be emitted. This also adjusts the pluralisation in a way I think is better.
1 parent c811aa7 commit 765e1c5

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

docs/source/command_line.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,10 @@ potentially problematic or redundant in some way.
440440
These two flags let you discover cases where either workarounds are
441441
no longer necessary.
442442

443-
.. option:: --disallow-ignore-without-code
443+
.. option:: --warn-ignores-without-codes
444444

445-
This flag will disallow ``# type: ignore`` comments which do not have
446-
error codes::
445+
This flag will make mypy report an error for any ``# type: ignore`` comments
446+
which do not have error codes::
447447

448448
prog.py:1: error: "type: ignore" comment without error code
449449

docs/source/config_file.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,12 @@ section of the command line docs.
507507

508508
Warns about unneeded ``# type: ignore`` comments.
509509

510-
.. confval:: disallow_ignore_without_code
510+
.. confval:: warn_ignores_without_codes
511511

512512
:type: boolean
513513
:default: False
514514

515-
Disallow ``# type: ignore`` comments which do not have error codes.
515+
Warn about '# type: ignore' comments which do not have error codes.
516516

517517
.. confval:: warn_no_return
518518

mypy/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2370,7 +2370,7 @@ def generate_unused_ignore_notes(self) -> None:
23702370
self.manager.errors.generate_unused_ignore_errors(self.xpath)
23712371

23722372
def generate_ignore_without_code_notes(self) -> None:
2373-
if self.options.disallow_ignore_without_code:
2373+
if self.options.warn_ignores_without_codes:
23742374
self.manager.errors.generate_ignore_without_code_errors(
23752375
self.xpath,
23762376
self.options.warn_unused_ignores,

mypy/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ def add_invertible_flag(flag: str,
637637
add_invertible_flag('--warn-unused-ignores', default=False, strict_flag=True,
638638
help="Warn about unneeded '# type: ignore' comments",
639639
group=lint_group)
640-
add_invertible_flag('--disallow-ignore-without-code', default=False,
640+
add_invertible_flag('--warn-ignores-without-codes', default=False,
641641
help="Disallow '# type: ignore' comments which do not have error codes",
642642
group=lint_group)
643643
add_invertible_flag('--no-warn-no-return', dest='warn_no_return', default=True,

mypy/options.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class BuildType:
3232
"disallow_any_expr",
3333
"disallow_any_generics",
3434
"disallow_any_unimported",
35-
"disallow_ignore_without_code",
3635
"disallow_incomplete_defs",
3736
"disallow_subclassing_any",
3837
"disallow_untyped_calls",
@@ -50,6 +49,7 @@ class BuildType:
5049
"strict_equality",
5150
"strict_optional",
5251
"strict_optional_whitelist",
52+
"warn_ignores_without_codes",
5353
"warn_no_return",
5454
"warn_return_any",
5555
"warn_unreachable",
@@ -144,8 +144,8 @@ def __init__(self) -> None:
144144
# Warn about unused '# type: ignore' comments
145145
self.warn_unused_ignores = False
146146

147-
# Warn about '# type: ignore' comments without error codes
148-
self.disallow_ignore_without_code = False
147+
# Warn about '# type: ignore' comments which do not have error codes
148+
self.warn_ignores_without_codes = False
149149

150150
# Warn about unused '[mypy-<pattern>]' or '[[tool.mypy.overrides]]' config sections
151151
self.warn_unused_configs = False

test-data/unit/check-errorcodes.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,16 @@ x # type: ignore[name-defined, attr-defined] # E: Unused "type: ignore[attr-defi
136136
"x" # type: ignore[name-defined] # E: Unused "type: ignore" comment
137137

138138
[case testErrorCodeMissingWhenRequired]
139-
# flags: --disallow-ignore-without-code
139+
# flags: --warn-ignores-without-codes
140140
"x" # type: ignore # E: "type: ignore" comment without error code
141141
y # type: ignore # E: "type: ignore" comment without error code (hint: add [name-defined])
142142

143143
[case testErrorCodeMissingDoesntTrampleUnusedIgnoresWarning]
144-
# flags: --disallow-ignore-without-code --warn-unused-ignores
144+
# flags: --warn-ignores-without-codes --warn-unused-ignores
145145
"x" # type: ignore # E: Unused "type: ignore" comment
146146

147147
[case testErrorCodeMissingWholeFileIgnores]
148-
# flags: --disallow-ignore-without-code
148+
# flags: --warn-ignores-without-codes
149149
# type: ignore # whole file ignore
150150
x
151151
y # type: ignore # ignore the lack of error code since we're ignore the whole file

0 commit comments

Comments
 (0)