diff --git a/python/src/com/jetbrains/python/codeInsight/completion/PySuperMethodCompletionContributor.java b/python/src/com/jetbrains/python/codeInsight/completion/PySuperMethodCompletionContributor.java index 213b6fbde809..4d276f1f0a78 100644 --- a/python/src/com/jetbrains/python/codeInsight/completion/PySuperMethodCompletionContributor.java +++ b/python/src/com/jetbrains/python/codeInsight/completion/PySuperMethodCompletionContributor.java @@ -66,6 +66,9 @@ public class PySuperMethodCompletionContributor extends CompletionContributor { for (PyFunction superMethod : ancestor.getMethods()) { if (!seenNames.contains(superMethod.getName())) { String text = superMethod.getName() + superMethod.getParameterList().getText(); + if (languageLevel.isAtLeast(LanguageLevel.PYTHON35) && superMethod.getAnnotation() != null) { + text += " " + superMethod.getAnnotation().getText(); + } LookupElementBuilder element = LookupElementBuilder.create(text); result.addElement(TailTypeDecorator.withTail(element, TailType.CASE_COLON)); seenNames.add(superMethod.getName()); diff --git a/python/testData/completion/superMethodWithAnnotation.after.py b/python/testData/completion/superMethodWithAnnotation.after.py new file mode 100644 index 000000000000..c498d16c9260 --- /dev/null +++ b/python/testData/completion/superMethodWithAnnotation.after.py @@ -0,0 +1,7 @@ +class Parent: + def overridable_method(param: str) -> Dict[str, str]: + pass + + +class Child(Parent): + def overridable_method(param: str) -> Dict[str, str]: \ No newline at end of file diff --git a/python/testData/completion/superMethodWithAnnotation.py b/python/testData/completion/superMethodWithAnnotation.py new file mode 100644 index 000000000000..82a7ad9e3248 --- /dev/null +++ b/python/testData/completion/superMethodWithAnnotation.py @@ -0,0 +1,7 @@ +class Parent: + def overridable_method(param: str) -> Dict[str, str]: + pass + + +class Child(Parent): + def over \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PythonCompletionTest.java b/python/testSrc/com/jetbrains/python/PythonCompletionTest.java index dc5a1b4860fa..00679715dbdd 100644 --- a/python/testSrc/com/jetbrains/python/PythonCompletionTest.java +++ b/python/testSrc/com/jetbrains/python/PythonCompletionTest.java @@ -314,6 +314,10 @@ public class PythonCompletionTest extends PyTestCase { doTest(); } + public void testSuperMethodWithAnnotation() { + runWithLanguageLevel(LanguageLevel.PYTHON35, this::doTest); + } + public void testLocalVarInDictKey() { // PY-2558 doTest(); }