Skip to content

Commit 26814f2

Browse files
committed
Avoid treating pass/... as no-op for reachability
Fixes #16232 The inclusion of these statements dates back to the original `--warn-unreachable` PR (and doesn't provide justification) I've been advocating for more consistent heuristics for allowable unreachable code across type checkers and I can't come up with a good reason that this should be allowed
1 parent 0a6f9ab commit 26814f2

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

mypy/checker.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3181,12 +3181,10 @@ def is_noop_for_reachability(self, s: Statement) -> bool:
31813181
return True
31823182
elif isinstance(s, ReturnStmt) and is_literal_not_implemented(s.expr):
31833183
return True
3184-
elif isinstance(s, (RaiseStmt, PassStmt)):
3184+
elif isinstance(s, RaiseStmt):
31853185
return True
31863186
elif isinstance(s, ExpressionStmt):
3187-
if isinstance(s.expr, EllipsisExpr):
3188-
return True
3189-
elif isinstance(s.expr, CallExpr):
3187+
if isinstance(s.expr, CallExpr):
31903188
with self.expr_checker.msg.filter_errors(filter_revealed_type=True):
31913189
typ = get_proper_type(
31923190
self.expr_checker.accept(

0 commit comments

Comments
 (0)