From 02188af64d2409450ba1fd133990bcb66524edc8 Mon Sep 17 00:00:00 2001 From: brovoski69 Date: Sun, 11 Jan 2026 00:52:16 +0530 Subject: [PATCH 1/6] Clarify --warn-unreachable behavior for pass statements --- docs/source/command_line.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/source/command_line.rst b/docs/source/command_line.rst index 310bb78a293b..b066b7f8dbd9 100644 --- a/docs/source/command_line.rst +++ b/docs/source/command_line.rst @@ -535,6 +535,15 @@ potentially problematic or redundant in some way. else: # Error: 'Statement is unreachable' error print(x + "bad") + Note that unreachable ``pass`` statements are intentionally not + reported by this option. This allows ``pass`` to be used as a + placeholder during development without triggering an error.For + example:: + + def f(x: int) -> None: + if x > 0: + return + pass # no --warn-unreachable error is reported here To help prevent mypy from generating spurious warnings, the "Statement is unreachable" warning will be silenced in exactly two cases: From b659d05855bcb6f644e617243f65dc3e2e5830c1 Mon Sep 17 00:00:00 2001 From: brovoski69 Date: Sun, 11 Jan 2026 01:01:59 +0530 Subject: [PATCH 2/6] Fix RST formatting for --warn-unreachable example --- docs/source/command_line.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/source/command_line.rst b/docs/source/command_line.rst index b066b7f8dbd9..cdf6b5d26e49 100644 --- a/docs/source/command_line.rst +++ b/docs/source/command_line.rst @@ -537,13 +537,15 @@ potentially problematic or redundant in some way. print(x + "bad") Note that unreachable ``pass`` statements are intentionally not reported by this option. This allows ``pass`` to be used as a - placeholder during development without triggering an error.For - example:: + placeholder during development without triggering an error. + + For example:: + + def f(x: int) -> None: + if x > 0: + return + pass # no --warn-unreachable error is reported here - def f(x: int) -> None: - if x > 0: - return - pass # no --warn-unreachable error is reported here To help prevent mypy from generating spurious warnings, the "Statement is unreachable" warning will be silenced in exactly two cases: From fd1837c59370f045c239743a58e8c09e3dfa3ef7 Mon Sep 17 00:00:00 2001 From: brovoski69 Date: Sun, 11 Jan 2026 01:12:58 +0530 Subject: [PATCH 3/6] Fix RST code block formatting for --warn-unreachable docs --- docs/source/command_line.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/command_line.rst b/docs/source/command_line.rst index cdf6b5d26e49..316da1da989c 100644 --- a/docs/source/command_line.rst +++ b/docs/source/command_line.rst @@ -539,7 +539,7 @@ potentially problematic or redundant in some way. reported by this option. This allows ``pass`` to be used as a placeholder during development without triggering an error. - For example:: + .. code-block:: python def f(x: int) -> None: if x > 0: From c47d3cb68bbc4fee649779788592e575b7699397 Mon Sep 17 00:00:00 2001 From: brovoski69 Date: Sun, 11 Jan 2026 01:45:33 +0530 Subject: [PATCH 4/6] Fix RST code block formatting for --warn-unreachable docs --- docs/source/command_line.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/command_line.rst b/docs/source/command_line.rst index 316da1da989c..b61ea668209f 100644 --- a/docs/source/command_line.rst +++ b/docs/source/command_line.rst @@ -541,10 +541,10 @@ potentially problematic or redundant in some way. .. code-block:: python - def f(x: int) -> None: - if x > 0: - return - pass # no --warn-unreachable error is reported here + def f(x: int) -> None: + if x > 0: + return + pass # no --warn-unreachable error is reported here To help prevent mypy from generating spurious warnings, the "Statement is From 4a22630b9ca08cf9914eb4a500a5d3144ba5bbbd Mon Sep 17 00:00:00 2001 From: brovoski69 Date: Sun, 11 Jan 2026 01:48:07 +0530 Subject: [PATCH 5/6] Fix RST code block formatting for --warn-unreachable docs --- docs/source/command_line.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/command_line.rst b/docs/source/command_line.rst index b61ea668209f..1b463f2e9b0c 100644 --- a/docs/source/command_line.rst +++ b/docs/source/command_line.rst @@ -535,6 +535,7 @@ potentially problematic or redundant in some way. else: # Error: 'Statement is unreachable' error print(x + "bad") + Note that unreachable ``pass`` statements are intentionally not reported by this option. This allows ``pass`` to be used as a placeholder during development without triggering an error. From 16003b1e8208d4a448f3650f8444505997000a3e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 10 Jan 2026 20:19:41 +0000 Subject: [PATCH 6/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/source/command_line.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/command_line.rst b/docs/source/command_line.rst index 1b463f2e9b0c..c9d09304777c 100644 --- a/docs/source/command_line.rst +++ b/docs/source/command_line.rst @@ -535,7 +535,7 @@ potentially problematic or redundant in some way. else: # Error: 'Statement is unreachable' error print(x + "bad") - + Note that unreachable ``pass`` statements are intentionally not reported by this option. This allows ``pass`` to be used as a placeholder during development without triggering an error.