mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-15867 Omit single star parameter in updated constructor signature if it's not followed by keyword-only parameters
This commit is contained in:
@@ -208,15 +208,21 @@ public class AddCallSuperQuickFix implements LocalQuickFix {
|
||||
}
|
||||
|
||||
// Required keyword-only parameters
|
||||
boolean hasKeywordOnlyParams = false;
|
||||
for (PyParameter param : origInfo.getRequiredKeywordOnlyParameters()) {
|
||||
newFunctionParams.add(param.getText());
|
||||
hasKeywordOnlyParams = true;
|
||||
}
|
||||
for (PyParameter param : superInfo.getRequiredKeywordOnlyParameters()) {
|
||||
if (!origInfo.getAllParameterNames().contains(param.getName())) {
|
||||
newFunctionParams.add(param.getText());
|
||||
hasKeywordOnlyParams = true;
|
||||
}
|
||||
superCallArgs.add(param.getName() + "=" + param.getName());
|
||||
}
|
||||
if (starredParam instanceof PySingleStarParameter && !hasKeywordOnlyParams) {
|
||||
newFunctionParams.remove(newFunctionParams.size() - 1);
|
||||
}
|
||||
|
||||
// Optional keyword-only parameters
|
||||
for (PyParameter param : origInfo.getOptionalKeywordOnlyParameters()) {
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class A:
|
||||
def __init__(self, a, b=1, *, kw_only=2):
|
||||
pass
|
||||
|
||||
|
||||
class B(A):
|
||||
def <warning descr="Call to __init__ of super class is missed">__i<caret>nit__</warning>(self):
|
||||
pass
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class A:
|
||||
def __init__(self, a, b=1, *, kw_only=2):
|
||||
pass
|
||||
|
||||
|
||||
class B(A):
|
||||
def __init__(self, a):
|
||||
super().__init__(a)
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class A:
|
||||
def __init__(self, *, a):
|
||||
pass
|
||||
|
||||
|
||||
class B(A):
|
||||
def <warning descr="Call to __init__ of super class is missed">__i<caret>nit__</warning>(self, a):
|
||||
pass
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class A:
|
||||
def __init__(self, *, a):
|
||||
pass
|
||||
|
||||
|
||||
class B(A):
|
||||
def __init__(self, a):
|
||||
super().__init__(a=a)
|
||||
@@ -115,6 +115,27 @@ public class Py3QuickFixTest extends PyTestCase {
|
||||
doInspectionTest(PyMissingConstructorInspection.class, PyBundle.message("QFIX.add.super"), true, true);
|
||||
}
|
||||
|
||||
// PY-15867
|
||||
public void testAddCallSuperNoRequiredKeywordOnlyParamAfterSingleStarInSuperInit() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON30, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doInspectionTest(PyMissingConstructorInspection.class, PyBundle.message("QFIX.add.super"), true, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// PY-15867
|
||||
public void testAddCallSuperRequiredKeywordOnlyParamAfterSingleStarInSuperInitIsMerged() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON30, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doInspectionTest(PyMissingConstructorInspection.class, PyBundle.message("QFIX.add.super"), true, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// PY-8991
|
||||
public void testRemoveUnicodePrefixFromGluedStringNodesWithSlash() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON32, new Runnable() {
|
||||
|
||||
Reference in New Issue
Block a user