public static boolean isInsideTypeHint(@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;
    }

    PyTypeAliasStatement typeAlias = PsiTreeUtil.getParentOfType(realContext, PyTypeAliasStatement.class, false, PyStatement.class);
    if (typeAlias != null && PsiTreeUtil.isAncestor(typeAlias.getTypeExpression(), realContext, false)) {
      return true;
    }

    return false;
  }
public static boolean isInsideTypeHint(@NotNull PsiElement element, @NotNull TypeEvalContext context)