From 613d59cb2aeb9418c448b8de89351d4e32770145 Mon Sep 17 00:00:00 2001 From: John Griffith Date: Mon, 14 Oct 2024 18:21:43 +0100 Subject: [PATCH 1/3] Add warn-unreachable to strict mode This is useful check for dead code analysis --- mypy/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/main.py b/mypy/main.py index 7bd7215bbe2a..1aeb78842468 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -825,7 +825,7 @@ def add_invertible_flag( add_invertible_flag( "--warn-unreachable", default=False, - strict_flag=False, + strict_flag=True, help="Warn about statements or expressions inferred to be unreachable", group=lint_group, ) From 3a052f8a473586558ff5d9c5aaf96d59a41ca54a Mon Sep 17 00:00:00 2001 From: wyattscarpenter Date: Tue, 6 May 2025 23:22:51 -0700 Subject: [PATCH 2/3] remove caveat about warn-unreachable from --strict documentation, as that is no longer true --- docs/source/command_line.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/source/command_line.rst b/docs/source/command_line.rst index b455e287017e..98a2a927689b 100644 --- a/docs/source/command_line.rst +++ b/docs/source/command_line.rst @@ -754,9 +754,6 @@ of the above sections. strict will catch type errors as long as intentional methods like type ignore or casting were not used.) - Note: the :option:`--warn-unreachable` flag - is not automatically enabled by the strict flag. - The strict flag does not take precedence over other strict-related flags. Directly specifying a flag of alternate behavior will override the behavior of strict, regardless of the order in which they are passed. From 168683d1d322f5b12fde0f671ced80778aca8264 Mon Sep 17 00:00:00 2001 From: wyattscarpenter Date: Wed, 7 May 2025 19:21:08 -0700 Subject: [PATCH 3/3] get rid of warn_unreachable in mypy_self_check.ini, as it is now redundant --- mypy_self_check.ini | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mypy_self_check.ini b/mypy_self_check.ini index 816e6321c06f..8b38cf7534a0 100644 --- a/mypy_self_check.ini +++ b/mypy_self_check.ini @@ -13,7 +13,3 @@ exclude = mypy/typeshed/|mypyc/test-data/|mypyc/lib-rt/ enable_error_code = ignore-without-code,redundant-expr enable_incomplete_feature = PreciseTupleTypes show_error_code_links = True - -[mypy-mypy.*] -# TODO: enable for `mypyc` and other files as well -warn_unreachable = True