@Nullable @Override public Ref<PyType> getReturnType(@NotNull PyCallable callable, @NotNull TypeEvalContext context) { if (callable instanceof PyFunction) { final PyFunction function = (PyFunction) callable; final PyAnnotation annotation = function.getAnnotation(); if (annotation != null) { // XXX: Requires switching from stub to AST final PyExpression value = annotation.getValue(); if (value != null) { final PyType type = getType(value, new Context(context)); return type != null ? Ref.create(type) : null; } } final PyType constructorType = getGenericConstructorType(function, new Context(context)); if (constructorType != null) { return Ref.create(constructorType); } final String comment = function.getTypeCommentAnnotation(); if (comment != null) { final PyTypeParser.ParseResult result = PyTypeParser.parsePep484FunctionTypeComment(callable, comment); final PyCallableType funcType = as(result.getType(), PyCallableType.class); if (funcType != null) { return Ref.create(funcType.getReturnType(context)); } } } return null; }