Skip to content

Commit

Permalink
Fix: for-loop index is only defined if iterable is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
NMertsch committed Sep 9, 2024
1 parent 65935c6 commit 55bfee2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mypy/partially_defined.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,9 @@ def visit_dictionary_comprehension(self, o: DictionaryComprehension) -> None:

def visit_for_stmt(self, o: ForStmt) -> None:
o.expr.accept(self)
self.tracker.start_branch_statement()
self.process_lvalue(o.index)
o.index.accept(self)
self.tracker.start_branch_statement()
loop = Loop()
self.loops.append(loop)
o.body.accept(self)
Expand Down

0 comments on commit 55bfee2

Please sign in to comment.