fixed PY-11109 Incorrect "Instance attribute defined outside __init__" in local classes

This commit is contained in:
Ekaterina Tuzova
2013-10-24 15:31:39 +04:00
parent eeb8d97dfa
commit c6f3fbab5d
3 changed files with 15 additions and 0 deletions
@@ -951,6 +951,9 @@ public class PyClassImpl extends PyPresentableElementImpl<PyClassStub> implement
final List<PyTargetExpression> result = new ArrayList<PyTargetExpression>();
if (statementList != null) {
statementList.accept(new PyRecursiveElementVisitor() {
@Override
public void visitPyClass(PyClass node) {}
public void visitPyAssignmentStatement(final PyAssignmentStatement node) {
for (PyExpression expression : node.getTargets()) {
if (expression instanceof PyTargetExpression) {
@@ -0,0 +1,8 @@
__author__ = 'ktisha'
class A:
def foo(self):
class B:
def __init__(self):
self.x = 1
@@ -58,6 +58,10 @@ public class PyAttributeOutsideInitInspectionTest extends PyTestCase {
doTest();
}
public void testInnerClass() {
doTest();
}
private void doTest() {
myFixture.configureByFile("inspections/PyAttributeOutsideInitInspection/" + getTestName(true) + ".py");
myFixture.enableInspections(PyAttributeOutsideInitInspection.class);