Skip to content

Commit 6728040

Browse files
pivot to --enable-all-error-codes flag
per the advice of the discussors of the github issue
1 parent 07710bf commit 6728040

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

mypy/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,11 @@ def add_invertible_flag(
953953
default=[],
954954
help="Enable a specific error code",
955955
)
956+
strictness_group.add_argument(
957+
"--enable-all-error-codes",
958+
action="store_true",
959+
help="Enable all error codes",
960+
)
956961

957962
error_group = parser.add_argument_group(
958963
title="Configuring error messages",

mypy/options.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ def __init__(self) -> None:
254254
# Error codes to enable
255255
self.enable_error_code: list[str] = []
256256
self.enabled_error_codes: set[ErrorCode] = set()
257+
self.enable_all_error_codes = False
257258

258259
# Use script name instead of __main__
259260
self.scripts_are_modules = False
@@ -451,7 +452,7 @@ def process_error_codes(self, *, error_callback: Callable[[str], Any]) -> None:
451452
error_callback(f"Invalid error code(s): {', '.join(sorted(invalid_codes))}")
452453

453454
self.disabled_error_codes |= {error_codes[code] for code in disabled_codes}
454-
if "all" in enabled_codes:
455+
if self.enable_all_error_codes:
455456
self.enabled_error_codes = set(error_codes.values())
456457
else:
457458
self.enabled_error_codes |= {error_codes[code] for code in enabled_codes}

test-data/unit/check-flags.test

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,8 +2468,8 @@ A = Union[C, List] # OK
24682468
def f():
24692469
x: int = "no" # N: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs
24702470

2471-
[case testSpotCheckErrorCodeAll]
2472-
# flags: --enable-error-code all
2471+
[case testSpotCheckEnableAllErrorCodes]
2472+
# flags: --enable-all-error-codes
24732473
# It would be annoying to check every error here, so let's just check a couple.
24742474
from typing_extensions import override
24752475

@@ -2489,13 +2489,12 @@ class Child(Parent):
24892489
pass
24902490
[builtins fixtures/tuple-simple.pyi]
24912491

2492-
[case testSpotCheckErrorCodeAllNotUsed]
2492+
[case testSpotCheckEnableAllErrorCodesNot]
24932493
# This test case exists purely to ensure that the testSpotCheckErrorCodeAll test does not become obsolete.
24942494
# (For example, if all the errors expected by testSpotCheckErrorCodeAll get turned on by default, then
24952495
# the testSpotCheckErrorCodeAll test would fail to guarantee the enablement of any additional errors!
24962496
# (hint: if that does happen, breaking this test, then consider changing these two tests to pick *different*,
24972497
# not-enabled-by-default, error codes.))
2498-
24992498
from typing_extensions import override
25002499

25012500
class Parent:

test-data/unit/fixtures/tuple-simple.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ class int: pass
2020
class str: pass # For convenience
2121
class dict: pass
2222

23-
# Had to define this testSpotCheckErrorCodeAll*, for whatever reason:
23+
# Had to define this for testSpotCheckErrorCodeAll*, for whatever reason:
2424
class ellipsis: pass

0 commit comments

Comments
 (0)