Ref<PyType> (@NotNull String contents, @NotNull PyTargetExpression target, @NotNull Context context) { final PyExpression expr = PyPsiUtils.flattenParens(toExpression(contents, target)); if (expr != null) { // Such syntax is specific to "# type:" comments, unpacking in type hints is not allowed anywhere else if (expr instanceof PyTupleExpression) { // XXX: Switches stub to AST final PyExpression topmostTarget = findTopmostTarget(target); if (topmostTarget != null) { final Map<PyTargetExpression, PyExpression> targetToExpr = mapTargetsToAnnotations(topmostTarget, expr); final PyExpression typeExpr = targetToExpr.get(target); if (typeExpr != null) { return getType(typeExpr, context); } } } else { return getType(expr, context); } } return null; }