PyExpression (@NotNull PyTargetExpression target) { final PyTargetExpressionStub stub = target.getStub(); PyExpression result = null; if (stub != null) { final PyTypingAliasStub aliasStub = stub.getCustomStub(PyTypingAliasStub.class); String aliasText = null; if (aliasStub != null) { aliasText = aliasStub.getText(); } else if (stub.getInitializerType() == InitializerType.ReferenceExpression) { aliasText = Objects.toString(stub.getInitializer(), null); } if (aliasText != null) { result = PyUtil.createExpressionFromFragment(aliasText, target.getContainingFile()); } } else { // Use PSI to get the assigned value but only if the same expression would be saved in stubs result = getAssignedValueIfTypeAliasLike(target, false); } return result; }