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

Method analyze_comp_for

mypy/semanal.py:6390–6404  ·  view source on GitHub ↗

Analyses the 'comp_for' part of comprehensions (part 1). That is the part after 'for' in (x for x in l if p). This analyzes variables and conditions which are analyzed in a local scope.

(self, expr: GeneratorExpr | DictionaryComprehension)

Source from the content-addressed store, hash-verified

6388 self.analyze_comp_for_2(expr)
6389
6390 def analyze_comp_for(self, expr: GeneratorExpr | DictionaryComprehension) -> None:
6391 """Analyses the 'comp_for' part of comprehensions (part 1).
6392
6393 That is the part after 'for' in (x for x in l if p). This analyzes
6394 variables and conditions which are analyzed in a local scope.
6395 """
6396 for i, (index, sequence, conditions) in enumerate(
6397 zip(expr.indices, expr.sequences, expr.condlists)
6398 ):
6399 if i > 0:
6400 sequence.accept(self)
6401 # Bind index variables.
6402 self.analyze_lvalue(index)
6403 for cond in conditions:
6404 cond.accept(self)
6405
6406 def analyze_comp_for_2(self, expr: GeneratorExpr | DictionaryComprehension) -> None:
6407 """Analyses the 'comp_for' part of comprehensions (part 2).

Callers 2

visit_generator_exprMethod · 0.95

Calls 4

analyze_lvalueMethod · 0.95
enumerateFunction · 0.85
zipFunction · 0.85
acceptMethod · 0.45

Tested by

no test coverage detected