(s: MatchStmt, options: Options)
| 77 | |
| 78 | |
| 79 | def infer_reachability_of_match_statement(s: MatchStmt, options: Options) -> None: |
| 80 | for i, guard in enumerate(s.guards): |
| 81 | pattern_value = infer_pattern_value(s.patterns[i]) |
| 82 | |
| 83 | if guard is not None: |
| 84 | guard_value = infer_condition_value(guard, options) |
| 85 | else: |
| 86 | guard_value = ALWAYS_TRUE |
| 87 | |
| 88 | if pattern_value in (ALWAYS_FALSE, MYPY_FALSE) or guard_value in ( |
| 89 | ALWAYS_FALSE, |
| 90 | MYPY_FALSE, |
| 91 | ): |
| 92 | # The case is considered always false, so we skip the case body. |
| 93 | mark_block_unreachable(s.bodies[i]) |
| 94 | elif pattern_value in (ALWAYS_TRUE, MYPY_TRUE) and guard_value in (ALWAYS_TRUE, MYPY_TRUE): |
| 95 | for body in s.bodies[i + 1 :]: |
| 96 | mark_block_unreachable(body) |
| 97 | |
| 98 | if guard_value == MYPY_TRUE: |
| 99 | # This condition is false at runtime; this will affect |
| 100 | # import priorities. |
| 101 | mark_block_mypy_only(s.bodies[i]) |
| 102 | |
| 103 | |
| 104 | def assert_will_always_fail(s: AssertStmt, options: Options) -> bool: |
no test coverage detected
searching dependent graphs…