From 0995772b24168a47049c35ed35825fc69a660316 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Mon, 27 Mar 2023 14:54:27 -0400 Subject: [PATCH] Explain why we ignore type check. --- src/allmydata/util/deferredutil.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/allmydata/util/deferredutil.py b/src/allmydata/util/deferredutil.py index 89dc9704c..58ca7dde0 100644 --- a/src/allmydata/util/deferredutil.py +++ b/src/allmydata/util/deferredutil.py @@ -239,6 +239,11 @@ def async_to_deferred(f: Callable[P, Awaitable[R]]) -> Callable[P, Deferred[R]]: @wraps(f) def not_async(*args: P.args, **kwargs: P.kwargs) -> Deferred[R]: + # Twisted documents fromCoroutine as accepting either a Generator or a + # Coroutine. However, the standard for type annotations of async + # functions is to return an Awaitable: + # https://github.com/twisted/twisted/issues/11832 + # So, we ignore the type warning. return defer.Deferred.fromCoroutine(f(*args, **kwargs)) # type: ignore return not_async