add TypeGuard to coroutines.iscoroutine (#6105)

make CoroutineType extend Coroutine
This commit is contained in:
KotlinIsland
2021-10-10 01:01:36 +10:00
committed by GitHub
parent e018ad66dc
commit b7d1d099d9
3 changed files with 21 additions and 9 deletions

View File

@@ -1,7 +1,16 @@
from typing import Any, Callable, TypeVar
import sys
import types
from collections.abc import Callable, Coroutine
from typing import Any, TypeVar
from typing_extensions import TypeGuard
_F = TypeVar("_F", bound=Callable[..., Any])
def coroutine(func: _F) -> _F: ...
def iscoroutinefunction(func: object) -> bool: ...
def iscoroutine(obj: object) -> bool: ...
if sys.version_info < (3, 8):
def iscoroutine(obj: object) -> TypeGuard[types.GeneratorType[Any, Any, Any] | Coroutine[Any, Any, Any]]: ...
else:
def iscoroutine(obj: object) -> TypeGuard[Coroutine[Any, Any, Any]]: ...