BranchState contains information about variable definition at the end of a branching statement. `if` and `match` are examples of branching statements. `may_be_defined` contains variables that were defined in only some branches. `must_be_defined` contains variables that were defined in a
| 49 | |
| 50 | |
| 51 | class BranchState: |
| 52 | """BranchState contains information about variable definition at the end of a branching statement. |
| 53 | `if` and `match` are examples of branching statements. |
| 54 | |
| 55 | `may_be_defined` contains variables that were defined in only some branches. |
| 56 | `must_be_defined` contains variables that were defined in all branches. |
| 57 | """ |
| 58 | |
| 59 | def __init__( |
| 60 | self, |
| 61 | must_be_defined: set[str] | None = None, |
| 62 | may_be_defined: set[str] | None = None, |
| 63 | skipped: bool = False, |
| 64 | ) -> None: |
| 65 | if may_be_defined is None: |
| 66 | may_be_defined = set() |
| 67 | if must_be_defined is None: |
| 68 | must_be_defined = set() |
| 69 | |
| 70 | self.may_be_defined = set(may_be_defined) |
| 71 | self.must_be_defined = set(must_be_defined) |
| 72 | self.skipped = skipped |
| 73 | |
| 74 | def copy(self) -> BranchState: |
| 75 | return BranchState( |
| 76 | must_be_defined=set(self.must_be_defined), |
| 77 | may_be_defined=set(self.may_be_defined), |
| 78 | skipped=self.skipped, |
| 79 | ) |
| 80 | |
| 81 | |
| 82 | class BranchStatement: |
no outgoing calls
no test coverage detected
searching dependent graphs…