Skip to content

Commit 465ea8c

Browse files
document, and add a new test
1 parent 6728040 commit 465ea8c

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

docs/source/command_line.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,24 @@ of the above sections.
799799
x = 'a string'
800800
x.trim() # error: "str" has no attribute "trim" [attr-defined]
801801
802+
.. option:: --enable-all-error-codes
803+
804+
This flag enables all of the error codes for mypy,
805+
including the optional ones that are off by default.
806+
See :ref:`error-codes` for more information.
807+
808+
This flag will override disabled error codes from the
809+
:option:`--disable-error-code <mypy --disable-error-code>` flag.
810+
811+
Note that future releases of mypy will likely introduce more error codes,
812+
so the effective behavior of this flag will change from release to release.
813+
814+
While often useful, this flag will enable **all** error codes,
815+
including those that may be experimental, wrongheaded, or contradictory.
816+
817+
It is not the same as enabling all checks that mypy could perform;
818+
for example, :option:`--strict-bytes` is not enabled by this flag.
819+
802820
.. _configuring-error-messages:
803821

804822
Configuring error messages

docs/source/config_file.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,15 @@ section of the command line docs.
761761

762762
Note: This option will override disabled error codes from the disable_error_code option.
763763

764+
.. confval:: enable_all_error_codes
765+
766+
:type: boolean
767+
:default: False
768+
769+
Enables all mypy error codes.
770+
771+
Note: This option will override disabled error codes from the disable_error_code option.
772+
764773
.. confval:: extra_checks
765774

766775
:type: boolean

test-data/unit/check-flags.test

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2494,7 +2494,7 @@ class Child(Parent):
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*,
2497-
# not-enabled-by-default, error codes.))
2497+
# not-enabled-by-default, error codes. Also, testSpotCheckEnableAllErrorCodesConfig.))
24982498
from typing_extensions import override
24992499

25002500
class Parent:
@@ -2512,3 +2512,25 @@ class Child(Parent):
25122512
def g(self, y: int) -> None: #type: ignore
25132513
pass
25142514
[builtins fixtures/tuple-simple.pyi]
2515+
2516+
[case testSpotCheckEnableAllErrorCodesConfig]
2517+
# flags: --config-file tmp/mypy.ini
2518+
# This test just makes sure that the user can still countermand
2519+
# enable_all_error_codes on a more-specific level.
2520+
import tests.foo
2521+
import bar
2522+
[file bar.py]
2523+
def foo() -> int: ...
2524+
if foo: ... # E: Function "foo" could always be true in boolean context
2525+
42 + "no" # type: ignore # E: "type: ignore" comment without error code (consider "type: ignore[operator]" instead)
2526+
[file tests/__init__.py]
2527+
[file tests/foo.py]
2528+
def foo() -> int: ...
2529+
if foo: ... # E: Function "foo" could always be true in boolean context
2530+
42 + "no" # type: ignore
2531+
[file mypy.ini]
2532+
\[mypy]
2533+
enable_all_error_codes = True
2534+
2535+
\[mypy-tests.*]
2536+
disable_error_code = ignore-without-code

0 commit comments

Comments
 (0)