diff --git a/python/src/com/jetbrains/python/inspections/quickfix/AddCallSuperQuickFix.java b/python/src/com/jetbrains/python/inspections/quickfix/AddCallSuperQuickFix.java index b3e9e2dd2386..2306a478adaa 100644 --- a/python/src/com/jetbrains/python/inspections/quickfix/AddCallSuperQuickFix.java +++ b/python/src/com/jetbrains/python/inspections/quickfix/AddCallSuperQuickFix.java @@ -149,15 +149,15 @@ public class AddCallSuperQuickFix implements LocalQuickFix { for (int i = 1; i != parameters.length; i++) { PyParameter p = parameters[i]; if (p.getDefaultValue() != null) continue; - String param; - param = p.getText(); - if (param.startsWith("**")) { + final String param = p.getName(); + String paramText = p.getText(); + if (paramText.startsWith("**")) { addDouble = true; if (doubleStarName == null) doubleStarName = p.getText(); continue; } - if (param.startsWith("*")) { + if (paramText.startsWith("*")) { addStar = true; if (starName == null) starName = p.getText(); diff --git a/python/testData/inspections/AddCallSuperAnnotations.py b/python/testData/inspections/AddCallSuperAnnotations.py new file mode 100644 index 000000000000..b50ae1b4fb72 --- /dev/null +++ b/python/testData/inspections/AddCallSuperAnnotations.py @@ -0,0 +1,8 @@ +class Example1: + def __init__(self, field1: str): + self.field1 = field1 + + +class Example2(Example1): + def __init__(self): ## Missed call to __init__ of super class + pass \ No newline at end of file diff --git a/python/testData/inspections/AddCallSuperAnnotations_after.py b/python/testData/inspections/AddCallSuperAnnotations_after.py new file mode 100644 index 000000000000..4bfd08c375e3 --- /dev/null +++ b/python/testData/inspections/AddCallSuperAnnotations_after.py @@ -0,0 +1,8 @@ +class Example1: + def __init__(self, field1: str): + self.field1 = field1 + + +class Example2(Example1): + def __init__(self, field1): + super().__init__(field1) \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyQuickFixTest.java b/python/testSrc/com/jetbrains/python/PyQuickFixTest.java index 29f8a1ac286f..2d9725025e22 100644 --- a/python/testSrc/com/jetbrains/python/PyQuickFixTest.java +++ b/python/testSrc/com/jetbrains/python/PyQuickFixTest.java @@ -270,7 +270,8 @@ public class PyQuickFixTest extends PyTestCase { myFixture.enableInspections(PyUnresolvedReferencesInspection.class); myFixture.configureByFile("UnresolvedRefNoCreateFunction.py"); myFixture.checkHighlighting(true, false, false); - final IntentionAction intentionAction = myFixture.getAvailableIntention(PyBundle.message("QFIX.unresolved.reference.create.function.$0", "ref")); + final IntentionAction intentionAction = myFixture.getAvailableIntention( + PyBundle.message("QFIX.unresolved.reference.create.function.$0", "ref")); assertNull(intentionAction); } @@ -314,6 +315,17 @@ public class PyQuickFixTest extends PyTestCase { PyBundle.message("QFIX.add.super"), true, true); } + public void testAddCallSuperAnnotations() { + runWithLanguageLevel(LanguageLevel.PYTHON33, new Runnable() { + @Override + public void run() { + doInspectionTest("AddCallSuperAnnotations.py", + PyMissingConstructorInspection.class, + PyBundle.message("QFIX.add.super"), true, true); + } + }); + } + public void testAddCallSuperPass() { //PY-8654 doInspectionTest("AddCallSuperPass.py", PyMissingConstructorInspection.class, PyBundle.message("QFIX.add.super"), true, true);