diff --git a/python/psi-api/src/com/jetbrains/python/psi/PyTargetExpression.java b/python/psi-api/src/com/jetbrains/python/psi/PyTargetExpression.java index 9012137bb53f..a248dee2d144 100644 --- a/python/psi-api/src/com/jetbrains/python/psi/PyTargetExpression.java +++ b/python/psi-api/src/com/jetbrains/python/psi/PyTargetExpression.java @@ -27,7 +27,7 @@ import org.jetbrains.annotations.Nullable; */ public interface PyTargetExpression extends PyQualifiedExpression, PsiNamedElement, PsiNameIdentifierOwner, PyDocStringOwner, PyQualifiedNameOwner, PyReferenceOwner, StubBasedPsiElement, - PyPossibleClassMember, PyTypeCommentOwner { + PyPossibleClassMember, PyTypeCommentOwner, PyAnnotationOwner { PyTargetExpression[] EMPTY_ARRAY = new PyTargetExpression[0]; /** diff --git a/python/src/com/jetbrains/python/codeInsight/PyTypingTypeProvider.java b/python/src/com/jetbrains/python/codeInsight/PyTypingTypeProvider.java index bf017fc484c0..3d9a6c001553 100644 --- a/python/src/com/jetbrains/python/codeInsight/PyTypingTypeProvider.java +++ b/python/src/com/jetbrains/python/codeInsight/PyTypingTypeProvider.java @@ -176,6 +176,15 @@ public class PyTypingTypeProvider extends PyTypeProviderBase { public PyType getReferenceType(@NotNull PsiElement referenceTarget, TypeEvalContext context, @Nullable PsiElement anchor) { if (referenceTarget instanceof PyTargetExpression) { final PyTargetExpression target = (PyTargetExpression)referenceTarget; + // XXX: Requires switching from stub to AST + final PyAnnotation annotation = target.getAnnotation(); + if (annotation != null) { + final PyExpression value = annotation.getValue(); + if (value != null) { + return getType(value, new Context(context)); + } + return null; + } final String comment = target.getTypeCommentAnnotation(); if (comment != null) { final PyType type = getStringBasedType(comment, referenceTarget, new Context(context)); diff --git a/python/src/com/jetbrains/python/psi/impl/PyTargetExpressionImpl.java b/python/src/com/jetbrains/python/psi/impl/PyTargetExpressionImpl.java index 868370081cc7..90e30082cf6e 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyTargetExpressionImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyTargetExpressionImpl.java @@ -214,6 +214,16 @@ public class PyTargetExpressionImpl extends PyBaseElementImpl