Skip to content

Commit 02188af

Browse files
committed
Clarify --warn-unreachable behavior for pass statements
1 parent 7285830 commit 02188af

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

docs/source/command_line.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,15 @@ potentially problematic or redundant in some way.
535535
else:
536536
# Error: 'Statement is unreachable' error
537537
print(x + "bad")
538+
Note that unreachable ``pass`` statements are intentionally not
539+
reported by this option. This allows ``pass`` to be used as a
540+
placeholder during development without triggering an error.For
541+
example::
542+
543+
def f(x: int) -> None:
544+
if x > 0:
545+
return
546+
pass # no --warn-unreachable error is reported here
538547

539548
To help prevent mypy from generating spurious warnings, the "Statement is
540549
unreachable" warning will be silenced in exactly two cases:

0 commit comments

Comments
 (0)