mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-20038 Fixed: "Call to __init__ of super class is missed" inspection if super is used with __class__
Update PyMissingConstructorInspection to honour __class__ as a first arg of super(...).__init__ call
This commit is contained in:
@@ -140,7 +140,8 @@ public class PyMissingConstructorInspection extends PyInspection {
|
||||
String firstArg = args[0].getText();
|
||||
final String qualifiedName = cl.getQualifiedName();
|
||||
if (firstArg.equals(cl.getName()) || firstArg.equals(CANONICAL_SELF+"."+ __CLASS__) ||
|
||||
(qualifiedName != null && qualifiedName.endsWith(firstArg)))
|
||||
(qualifiedName != null && qualifiedName.endsWith(firstArg)) ||
|
||||
(LanguageLevel.forElement(cl).isAtLeast(LanguageLevel.PYTHON30) && firstArg.equals(__CLASS__)))
|
||||
return true;
|
||||
for (PyClass s : cl.getAncestorClasses(myTypeEvalContext)) {
|
||||
if (firstArg.equals(s.getName()))
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class First:
|
||||
def __init__(self):
|
||||
print('First inited')
|
||||
|
||||
|
||||
class Second(First):
|
||||
def __init__(self):
|
||||
super(__class__, self).__init__()
|
||||
print('Second inited')
|
||||
@@ -44,7 +44,12 @@ public class PyMissingConstructorTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDunderClass() { // PY-4038
|
||||
public void testExplicitDunderClass() { // PY-4038
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testImplicitDunderClass() { // PY-20038
|
||||
setLanguageLevel(LanguageLevel.PYTHON30);
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user