PY-41976 Fix deleting stars from keywords and positional container

(cherry picked from commit 73e4d785ed2e4aa247a5a5dd0f158701bbbee196)

IJ-MR-4706

GitOrigin-RevId: 02c17f0a492647083df9fb6af0213a17d0406c8a
This commit is contained in:
andrey.matveev
2020-12-17 12:54:44 +00:00
committed by intellij-monorepo-bot
parent 3b99571638
commit 5db655539e
6 changed files with 25 additions and 1 deletions
@@ -92,7 +92,13 @@ public class SpecifyTypeInPy3AnnotationsIntention extends TypeIntention {
boolean createTemplate) {
final PyExpression defaultParamValue = parameter.getDefaultValue();
final String paramName = StringUtil.notNullize(parameter.getName());
String paramName = StringUtil.notNullize(parameter.getName());
if (parameter.isPositionalContainer()) {
paramName = "*" + paramName;
}
else if (parameter.isKeywordContainer()) {
paramName = "**" + paramName;
}
final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project);
final String defaultParamText = defaultParamValue == null ? null : defaultParamValue.getText();
@@ -0,0 +1,2 @@
def fo<caret>o(**x):
pass
@@ -0,0 +1,2 @@
def foo(**x: object<caret>) -> object:
pass
@@ -0,0 +1,2 @@
def fo<caret>o(*x, **y):
pass
@@ -0,0 +1,2 @@
def foo(*x: object<caret>, **y: object) -> object:
pass
@@ -46,6 +46,16 @@ public class PyAnnotateTypesIntentionTest extends PyIntentionTestCase {
doIntentionTest(PyPsiBundle.message("INTN.add.type.hints.for.function", "method"));
}
// PY-41976
public void testFunctionKeywordContainerParameter() {
doTest();
}
// PY-41976
public void testFunctionPositionalAndKeywordContainerParameter() {
doTest();
}
private void doTest() {
doTest(PyPsiBundle.message("INTN.NAME.add.type.hints.for.function"), LanguageLevel.PYTHON34);
}