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

Method visit_for_stmt

mypy/semanal.py:5494–5517  ·  view source on GitHub ↗
(self, s: ForStmt)

Source from the content-addressed store, hash-verified

5492 self.visit_block_maybe(s.else_body)
5493
5494 def visit_for_stmt(self, s: ForStmt) -> None:
5495 if s.is_async:
5496 if not self.is_func_scope() or not self.function_stack[-1].is_coroutine:
5497 self.fail(message_registry.ASYNC_FOR_OUTSIDE_COROUTINE, s, code=codes.SYNTAX)
5498
5499 self.statement = s
5500 s.expr.accept(self)
5501
5502 # Bind index variables and check if they define new names.
5503 self.analyze_lvalue(s.index, explicit_type=s.index_type is not None, is_index_var=True)
5504 if s.index_type:
5505 if self.is_classvar(s.index_type):
5506 self.fail_invalid_classvar(s.index)
5507 allow_tuple_literal = isinstance(s.index, TupleExpr)
5508 analyzed = self.anal_type(s.index_type, allow_tuple_literal=allow_tuple_literal)
5509 if analyzed is not None:
5510 self.store_declared_types(s.index, analyzed)
5511 s.index_type = analyzed
5512
5513 self.loop_depth[-1] += 1
5514 with self.inside_except_star_block_set(value=False, entering_loop=True):
5515 self.visit_block(s.body)
5516 self.loop_depth[-1] -= 1
5517 self.visit_block_maybe(s.else_body)
5518
5519 def visit_break_stmt(self, s: BreakStmt) -> None:
5520 self.statement = s

Callers

nothing calls this directly

Calls 12

is_func_scopeMethod · 0.95
failMethod · 0.95
analyze_lvalueMethod · 0.95
is_classvarMethod · 0.95
fail_invalid_classvarMethod · 0.95
anal_typeMethod · 0.95
store_declared_typesMethod · 0.95
visit_blockMethod · 0.95
visit_block_maybeMethod · 0.95
isinstanceFunction · 0.85
acceptMethod · 0.45

Tested by

no test coverage detected