PyExpression (@NotNull PyTargetExpression target, boolean forStubCreation) { if (!PyUtil.isTopLevel(target) || !looksLikeTypeAliasTarget(target)) { return null; } final PyExpression value = target.findAssignedValue(); // Plain reference expressions are handled by PyTargetExpressionStub.getInitializer() // when initializer type is ReferenceExpression. We don't want to override these stubs, // so as not to break existing resolve functionality (see PyTargetExpression.getAssignedQName()). if (value == null || forStubCreation && value instanceof PyReferenceExpression) { return null; } if (isExplicitTypeAlias(target) || looksLikeTypeHint(value)) { return value; } return null; }