PY-16412 Properly import named tuples for their use in type hints

For that I introduced a new method -- getElement() in PyType
that allows to find out the element that can be used to reference
this type according to PEP 484 perspective, e.g. a target assignment
for TypeVar's and NamedTuples and PSI class themselves for class types.

Also, class object types for named tuples are wrapped in typing.Type[]
as expected.
This commit is contained in:
Mikhail Golubev
2018-02-05 21:41:59 +03:00
committed by Andrey Vlasovskikh
parent d1ae008593
commit af64e90b62
23 changed files with 177 additions and 38 deletions
@@ -231,6 +231,26 @@ public class PyAnnotateVariableTypeIntentionTest extends PyIntentionTestCase {
doAnnotationTest();
}
public void testAnnotationTypingNamedTupleInOtherFile() {
doMultiFileAnnotationTest();
}
public void testAnnotationTypingNamedTupleClassInOtherFile() {
doMultiFileAnnotationTest();
}
public void testAnnotationTypingNamedTupleDirectInheritorInOtherFile() {
doMultiFileAnnotationTest();
}
public void testAnnotationCollectionsNamedTupleInOtherFile() {
doMultiFileAnnotationTest();
}
public void testAnnotationCollectionsNamedTupleClassInOtherFile() {
doMultiFileAnnotationTest();
}
public void testConflictWithAnnotationFunctionTypeIntention() {
doTest(LanguageLevel.PYTHON36);
}