PyType (@NotNull PyFunction function, @Nullable PyType returnType) { if (function.isAsync() && function.isAsyncAllowed()) { if (!function.isGenerator()) { return wrapInCoroutineType(returnType, function); } else if (returnType instanceof PyCollectionType && isGenerator(returnType)) { return wrapInAsyncGeneratorType(((PyCollectionType)returnType).getIteratedItemType(), function); } } return returnType; }