File tree Expand file tree Collapse file tree 2 files changed +18
-13
lines changed Expand file tree Collapse file tree 2 files changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -5054,19 +5054,7 @@ def _visit_if_stmt_redundant_expr_helper(
50545054 def _filter (body : Block | None ) -> bool :
50555055 if body is None :
50565056 return False
5057- s = body .body [0 ]
5058- if isinstance (s , AssertStmt ) and is_false_literal (s .expr ):
5059- return True
5060- if isinstance (s , RaiseStmt ):
5061- return True
5062- elif isinstance (s , ExpressionStmt ) and isinstance (s .expr , CallExpr ):
5063- with self .expr_checker .msg .filter_errors (filter_revealed_type = True ):
5064- typ = self .expr_checker .accept (
5065- s .expr , allow_none_return = True , always_allow_any = True
5066- )
5067- if isinstance (get_proper_type (typ ), UninhabitedType ):
5068- return True
5069- return False
5057+ return all (self .is_noop_for_reachability (s ) for s in body .body )
50705058
50715059 if if_map is None :
50725060 if stmt .while_stmt :
Original file line number Diff line number Diff line change @@ -3137,4 +3137,21 @@ def f6(x: Literal[1]) -> None:
31373137 if x != 1:
31383138 raise ValueError
31393139
3140+ def f7(x: Literal[1, 2]) -> None:
3141+ if x == 1:
3142+ y = "a"
3143+ elif x == 2:
3144+ y = "b"
3145+ else:
3146+ pass
3147+
3148+ def f8(x: Literal[1, 2]) -> None:
3149+ if x == 1:
3150+ y = "a"
3151+ elif x == 2: # E: If condition is always true
3152+ y = "b"
3153+ else:
3154+ pass
3155+ y = "c"
3156+
31403157[builtins fixtures/bool.pyi]
You can’t perform that action at this time.
0 commit comments