Skip to content

Commit 091c021

Browse files
committed
Group --disallow-ignore-without-code with --warn-unused-ignores
Also make it non-strict for now. It may become part of --strict in the future, though work may be needed to reduce the number of 'misc' errors before then.
1 parent b678dd4 commit 091c021

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

docs/source/command_line.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,15 @@ 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
444+
445+
This flag will disallow ``type: ignore`` comments which do not have
446+
error codes::
447+
448+
prog.py:1: error: "type: ignore" comment without error code
449+
450+
See :ref:`error-codes` for more information.
451+
443452
.. option:: --no-warn-no-return
444453

445454
By default, mypy will generate errors when a function is missing
@@ -680,15 +689,6 @@ in error messages.
680689

681690
See :ref:`error-codes` for more information.
682691

683-
.. option:: --disallow-ignore-without-code
684-
685-
This flag will disallow ``type: ignore`` comments which do not have
686-
error codes::
687-
688-
prog.py:1: error: "type: ignore" comment without error code
689-
690-
See :ref:`error-codes` for more information.
691-
692692
.. option:: --pretty
693693

694694
Use visually nicer output in error messages: use soft word wrap,

mypy/main.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,9 @@ 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,
641+
help="Disallow '# type: ignore' comments which do not have error codes",
642+
group=lint_group)
640643
add_invertible_flag('--no-warn-no-return', dest='warn_no_return', default=True,
641644
help="Do not warn about functions that end without returning",
642645
group=lint_group)
@@ -677,10 +680,6 @@ def add_invertible_flag(flag: str,
677680
" non-overlapping types",
678681
group=strictness_group)
679682

680-
add_invertible_flag('--disallow-ignore-without-code', default=False, strict_flag=True,
681-
help="Disallow 'type: ignore' comments which do not have error codes",
682-
group=strictness_group)
683-
684683
strict_help = "Strict mode; enables the following flags: {}".format(
685684
", ".join(strict_flag_names))
686685
strictness_group.add_argument(

0 commit comments

Comments
 (0)