diff --git a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInPy3AnnotationsIntention.java b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInPy3AnnotationsIntention.java index 806b2e41a2a1..30cb3c89bc85 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInPy3AnnotationsIntention.java +++ b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInPy3AnnotationsIntention.java @@ -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(); diff --git a/python/testData/intentions/PyAnnotateTypesIntentionTest/functionKeywordContainerParameter.py b/python/testData/intentions/PyAnnotateTypesIntentionTest/functionKeywordContainerParameter.py new file mode 100644 index 000000000000..6b6c62d5d83d --- /dev/null +++ b/python/testData/intentions/PyAnnotateTypesIntentionTest/functionKeywordContainerParameter.py @@ -0,0 +1,2 @@ +def foo(**x): + pass \ No newline at end of file diff --git a/python/testData/intentions/PyAnnotateTypesIntentionTest/functionKeywordContainerParameter_after.py b/python/testData/intentions/PyAnnotateTypesIntentionTest/functionKeywordContainerParameter_after.py new file mode 100644 index 000000000000..be4b0bbae0ff --- /dev/null +++ b/python/testData/intentions/PyAnnotateTypesIntentionTest/functionKeywordContainerParameter_after.py @@ -0,0 +1,2 @@ +def foo(**x: object) -> object: + pass \ No newline at end of file diff --git a/python/testData/intentions/PyAnnotateTypesIntentionTest/functionPositionalAndKeywordContainerParameter.py b/python/testData/intentions/PyAnnotateTypesIntentionTest/functionPositionalAndKeywordContainerParameter.py new file mode 100644 index 000000000000..b653f48634ba --- /dev/null +++ b/python/testData/intentions/PyAnnotateTypesIntentionTest/functionPositionalAndKeywordContainerParameter.py @@ -0,0 +1,2 @@ +def foo(*x, **y): + pass \ No newline at end of file diff --git a/python/testData/intentions/PyAnnotateTypesIntentionTest/functionPositionalAndKeywordContainerParameter_after.py b/python/testData/intentions/PyAnnotateTypesIntentionTest/functionPositionalAndKeywordContainerParameter_after.py new file mode 100644 index 000000000000..34c7f8cb394e --- /dev/null +++ b/python/testData/intentions/PyAnnotateTypesIntentionTest/functionPositionalAndKeywordContainerParameter_after.py @@ -0,0 +1,2 @@ +def foo(*x: object, **y: object) -> object: + pass \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/intentions/PyAnnotateTypesIntentionTest.java b/python/testSrc/com/jetbrains/python/intentions/PyAnnotateTypesIntentionTest.java index 5d8a73fbae51..ef00da2c9ded 100644 --- a/python/testSrc/com/jetbrains/python/intentions/PyAnnotateTypesIntentionTest.java +++ b/python/testSrc/com/jetbrains/python/intentions/PyAnnotateTypesIntentionTest.java @@ -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); }