PY-16412 Import Type for annotations containing types of class objects

This commit is contained in:
Mikhail Golubev
2018-02-05 21:41:59 +03:00
committed by Andrey Vlasovskikh
parent 7c5c6d1a7e
commit 034f409a6a
4 changed files with 20 additions and 0 deletions
@@ -304,6 +304,9 @@ public class PyTypeHintGenerationUtil {
collectImportTargetsFromType(pyType, classes, names);
}
}
if (type instanceof PyInstantiableType && ((PyInstantiableType)type).isDefinition()) {
names.add("Type");
}
}
public static final class AnnotationInfo {
@@ -0,0 +1,5 @@
class Foo:
pass
va<caret>r = Foo
@@ -0,0 +1,8 @@
from typing import Type
class Foo:
pass
var: [Type[Foo]] = Foo
@@ -199,6 +199,10 @@ public class PyAnnotateVariableTypeIntentionTest extends PyIntentionTestCase {
doAnnotationTest();
}
public void testAnnotationClassObjectType() {
doAnnotationTest();
}
private void doAnnotationTest() {
doTest(LanguageLevel.PYTHON36);
}