reword typeguard comment to be updated

This commit is contained in:
Zomatree
2022-10-10 00:18:24 +01:00
parent c531aa649e
commit b3e1ffa3bb
+3 -3
View File
@@ -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)