MCPcopy
hub / github.com/python/mypy / ForStmt

Class ForStmt

mypy/nodes.py:1950–2001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1948
1949
1950class ForStmt(Statement):
1951 __slots__ = (
1952 "index",
1953 "index_type",
1954 "unanalyzed_index_type",
1955 "inferred_item_type",
1956 "inferred_iterator_type",
1957 "expr",
1958 "body",
1959 "else_body",
1960 "is_async",
1961 )
1962
1963 __match_args__ = ("index", "index_type", "expr", "body", "else_body")
1964
1965 # Index variables
1966 index: Lvalue
1967 # Type given by type comments for index, can be None
1968 index_type: mypy.types.Type | None
1969 # Original, not semantically analyzed type in annotation (used for reprocessing)
1970 unanalyzed_index_type: mypy.types.Type | None
1971 # Inferred iterable item type
1972 inferred_item_type: mypy.types.Type | None
1973 # Inferred iterator type
1974 inferred_iterator_type: mypy.types.Type | None
1975 # Expression to iterate
1976 expr: Expression
1977 body: Block
1978 else_body: Block | None
1979 is_async: bool # True if `async for ...` (PEP 492, Python 3.5)
1980
1981 def __init__(
1982 self,
1983 index: Lvalue,
1984 expr: Expression,
1985 body: Block,
1986 else_body: Block | None,
1987 index_type: mypy.types.Type | None = None,
1988 ) -> None:
1989 super().__init__()
1990 self.index = index
1991 self.index_type = index_type
1992 self.unanalyzed_index_type = index_type
1993 self.inferred_item_type = None
1994 self.inferred_iterator_type = None
1995 self.expr = expr
1996 self.body = body
1997 self.else_body = else_body
1998 self.is_async = False
1999
2000 def accept(self, visitor: StatementVisitor[T]) -> T:
2001 return visitor.visit_for_stmt(self)
2002
2003
2004class ReturnStmt(Statement):

Callers 4

visit_ForMethod · 0.90
visit_AsyncForMethod · 0.90
visit_for_stmtMethod · 0.90
read_statementFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…