MCPcopy Index your code
hub / github.com/python/mypy / BranchState

Class BranchState

mypy/partially_defined.py:51–79  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

49
50
51class 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
82class BranchStatement:

Callers 4

copyMethod · 0.85
__init__Method · 0.85
next_branchMethod · 0.85
doneMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…