diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyTypeHintGenerationUtil.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyTypeHintGenerationUtil.java index 9ec23b4b8fe1..b36fbcba8be1 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyTypeHintGenerationUtil.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyTypeHintGenerationUtil.java @@ -305,6 +305,9 @@ public class PyTypeHintGenerationUtil { classes.add(pyClass); } } + else if (type instanceof PyTupleType) { + names.add("Tuple"); + } for (PyType pyType : ((PyCollectionType)type).getElementTypes()) { collectImportTargetsFromType(pyType, classes, names); } diff --git a/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationTupleType.py b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationTupleType.py new file mode 100644 index 000000000000..c7651286d18c --- /dev/null +++ b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationTupleType.py @@ -0,0 +1 @@ +var = (1, 'foo', None) \ No newline at end of file diff --git a/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationTupleType_after.py b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationTupleType_after.py new file mode 100644 index 000000000000..fe382ba86b97 --- /dev/null +++ b/python/testData/intentions/PyAnnotateVariableTypeIntentionTest/annotationTupleType_after.py @@ -0,0 +1,3 @@ +from typing import Tuple + +var: [Tuple[int, str, None]] = (1, 'foo', None) \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/intentions/PyAnnotateVariableTypeIntentionTest.java b/python/testSrc/com/jetbrains/python/intentions/PyAnnotateVariableTypeIntentionTest.java index f5c649d8ab02..16e885f24ad5 100644 --- a/python/testSrc/com/jetbrains/python/intentions/PyAnnotateVariableTypeIntentionTest.java +++ b/python/testSrc/com/jetbrains/python/intentions/PyAnnotateVariableTypeIntentionTest.java @@ -207,6 +207,10 @@ public class PyAnnotateVariableTypeIntentionTest extends PyIntentionTestCase { doAnnotationTest(); } + public void testAnnotationTupleType() { + doAnnotationTest(); + } + private void doAnnotationTest() { doTest(LanguageLevel.PYTHON36); }