From b3e1ffa3bbd987da84c853c26a8d354a809081b1 Mon Sep 17 00:00:00 2001 From: Zomatree Date: Mon, 10 Oct 2022 00:18:24 +0100 Subject: [PATCH] reword typeguard comment to be updated --- revolt/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/revolt/utils.py b/revolt/utils.py index b99f0a2..9ff4205 100755 --- a/revolt/utils.py +++ b/revolt/utils.py @@ -26,9 +26,9 @@ def copy_doc(from_t: T) -> Callable[[T], T]: R_T = TypeVar("R_T") P = ParamSpec("P") -# it is impossible to type this function correctly for a couple reasons: -# 1. isawaitable does not narrow while keeping typevars - there is an open PR for this (typeshed#5658) but it cannot be merged because mypy does not support the feature fully -# 2. typeguard does not narrow for the negative case which is dumb in my opinion, so `value` would stay being a union even after the if statement (PEP 647 - "The type is not narrowed in the negative case") +# it is impossible to type this function correctly as typeguard does not narrow for the negative case, +# so `value` would stay being a union even after the if statement (PEP 647 - "The type is not narrowed in the negative case") +# see typing#926, typing#930, typing#996 async def maybe_coroutine(func: Callable[P, Union[R_T, Coroutine[Any, Any, R_T]]], *args: P.args, **kwargs: P.kwargs) -> R_T: value = func(*args, **kwargs)