fixed PY-9496 Don't show warnings about base classes without __init__

PY-9302 Class has no __init__ method: false positive for child class without one
This commit is contained in:
Ekaterina Tuzova
2013-07-25 17:52:39 +04:00
parent 718b14afa7
commit fc02fb5ca5
2 changed files with 1 additions and 8 deletions
@@ -53,13 +53,6 @@ public class PyClassHasNoInitInspection extends PyInspection {
registerProblem(node.getNameIdentifier(), PyBundle.message("INSP.class.has.no.init"),
new AddMethodQuickFix("__init__", new PyClassTypeImpl(node, false), false));
}
for (PyClass ancestor : node.getAncestorClasses(myTypeEvalContext)) {
final PyFunction ancestorInit = ancestor.findInitOrNew(false);
if (ancestorInit == null) {
registerProblem(node.getNameIdentifier(), PyBundle.message("INSP.parent.$0.has.no.init", ancestor.getName()),
new AddMethodQuickFix("__init__", new PyClassTypeImpl(ancestor, false), false));
}
}
}
}
}
@@ -3,7 +3,7 @@ class <weak_warning descr="Class has no __init__ method">A</weak_warning>:
def foo(self):
self.b = 1
class <weak_warning descr="Parent 'A' has no __init__ method">B</weak_warning>(A):
class B(A):
def __init__(self):
self.b = 2