PY-1359 "Unassigned local variable" inspection doesn't handle empty loops correctly

This commit is contained in:
Oleg Shpynov
2010-07-21 18:46:38 +04:00
parent 521b1aadf6
commit d2e07e7802
2 changed files with 7 additions and 1 deletions
@@ -81,7 +81,8 @@ public class PyUnboundLocalVariableInspection extends PyInspection {
continue;
}
}
if (PyAssignmentStatementNavigator.getStatementByTarget(element) != null) {
if (PyAssignmentStatementNavigator.getStatementByTarget(element) != null ||
PyForStatementNavigator.getPyForStatementByIterable(element) != null) {
resolves2LocalVariable = true;
resolve2Scope = PsiTreeUtil.isAncestor(owner, element, false);
break;
@@ -10,4 +10,9 @@
<line>14</line>
<description>"Name 'b' can be not defined"</description>
</problem>
<problem>
<file>test.py</file>
<line>51</line>
<description>"Name 'i' can be not defined"</description>
</problem>
</problems>