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

Method visit_break_stmt

mypy/partially_defined.py:512–524  ·  view source on GitHub ↗
(self, o: BreakStmt)

Source from the content-addressed store, hash-verified

510 self.tracker.skip_branch()
511
512 def visit_break_stmt(self, o: BreakStmt) -> None:
513 super().visit_break_stmt(o)
514 if self.loops:
515 self.loops[-1].has_break = True
516 # Track variables that are definitely defined at the point of break
517 if len(self.tracker._scope().branch_stmts) > 0:
518 branch = self.tracker._scope().branch_stmts[-1].branches[-1]
519 if self.loops[-1].break_vars is None:
520 self.loops[-1].break_vars = set(branch.must_be_defined)
521 else:
522 # we only want variables that have been defined in each branch
523 self.loops[-1].break_vars.intersection_update(branch.must_be_defined)
524 self.tracker.skip_branch()
525
526 def visit_expression_stmt(self, o: ExpressionStmt) -> None:
527 typ = self.type_map.get(o.expr)

Callers

nothing calls this directly

Calls 4

lenFunction · 0.85
setClass · 0.85
_scopeMethod · 0.80
skip_branchMethod · 0.45

Tested by

no test coverage detected