boolean (@NotNull PsiElement element, @NotNull TypeEvalContext context) { final PsiElement realContext = PyPsiUtils.getRealContext(element); if (PsiTreeUtil.getParentOfType(realContext, PyAnnotation.class, false, PyStatement.class) != null) { return true; } final PsiComment comment = PsiTreeUtil.getParentOfType(realContext, PsiComment.class, false, PyStatement.class); if (comment != null && getTypeCommentValue(comment.getText()) != null) { return true; } PyAssignmentStatement assignment = PsiTreeUtil.getParentOfType(realContext, PyAssignmentStatement.class, false, PyStatement.class); if (assignment != null && PsiTreeUtil.isAncestor(assignment.getAssignedValue(), realContext, false) && isExplicitTypeAlias(assignment, context)) { return true; } return false; }