PY-16412 Import Tuple for parametrized types of tuples

This commit is contained in:
Mikhail Golubev
2018-02-05 21:41:59 +03:00
committed by Andrey Vlasovskikh
parent f27611869f
commit 28e74fcc04
4 changed files with 11 additions and 0 deletions
@@ -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);
}
@@ -0,0 +1 @@
v<caret>ar = (1, 'foo', None)
@@ -0,0 +1,3 @@
from typing import Tuple
var: [Tuple[int, str, None]] = (1, 'foo', None)
@@ -207,6 +207,10 @@ public class PyAnnotateVariableTypeIntentionTest extends PyIntentionTestCase {
doAnnotationTest();
}
public void testAnnotationTupleType() {
doAnnotationTest();
}
private void doAnnotationTest() {
doTest(LanguageLevel.PYTHON36);
}