mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-11561 Preserve existing type annotations in the modified constructor
This commit is contained in:
@@ -91,7 +91,11 @@ public class AddCallSuperQuickFix implements LocalQuickFix {
|
||||
newFunction.append(", ");
|
||||
}
|
||||
StringUtil.join(newParameters, ", ", newFunction);
|
||||
newFunction.append("):\n\t");
|
||||
newFunction.append(")");
|
||||
if (problemFunction.getAnnotation() != null) {
|
||||
newFunction.append(problemFunction.getAnnotation().getText());
|
||||
}
|
||||
newFunction.append(":\n\t");
|
||||
|
||||
final List<String> superCallArguments = couple.getSecond();
|
||||
if (addComma && !superCallArguments.isEmpty()) {
|
||||
|
||||
@@ -4,5 +4,5 @@ class Example1:
|
||||
|
||||
|
||||
class Example2(Example1):
|
||||
def __init__(self, field1):
|
||||
def __init__(self, field1: str):
|
||||
super().__init__(field1)
|
||||
@@ -0,0 +1,7 @@
|
||||
class A:
|
||||
def __init__(self, a:int, b:float, *args:tuple, c:complex, **kwargs:dict) -> None:
|
||||
pass
|
||||
|
||||
class B(A):
|
||||
def <warning descr="Call to __init__ of super class is missed">__i<caret>nit__</warning>(self, d:str, *, e:bytes) -> list:
|
||||
pass
|
||||
@@ -0,0 +1,7 @@
|
||||
class A:
|
||||
def __init__(self, a:int, b:float, *args:tuple, c:complex, **kwargs:dict) -> None:
|
||||
pass
|
||||
|
||||
class B(A):
|
||||
def __init__(self, d:str, a:int, b:float, *args:tuple, e:bytes, c:complex, **kwargs:dict) -> list:
|
||||
super().__init__(a, b, *args, c=c, **kwargs)
|
||||
@@ -400,7 +400,17 @@ public class PyQuickFixTest extends PyTestCase {
|
||||
PyBundle.message("QFIX.add.super"), true, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// PY-15867
|
||||
public void testAddCallSuperTypeAnnotationsPreserved() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON30, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doInspectionTest("AddCallSuperTypeAnnotationsPreserved.py", PyMissingConstructorInspection.class,
|
||||
PyBundle.message("QFIX.add.super"), true, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//PY-491, PY-13297
|
||||
|
||||
Reference in New Issue
Block a user