-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathcoroutines.pyi
More file actions
47 lines (40 loc) · 2.24 KB
/
coroutines.pyi
File metadata and controls
47 lines (40 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import sys
from collections.abc import Awaitable, Callable, Coroutine
from typing import Any, TypeVar, overload
from typing_extensions import ParamSpec, TypeGuard, TypeIs, deprecated
# Keep asyncio.__all__ updated with any changes to __all__ here
if sys.version_info >= (3, 11):
__all__ = ("iscoroutinefunction", "iscoroutine")
else:
__all__ = ("coroutine", "iscoroutinefunction", "iscoroutine")
_T = TypeVar("_T")
_FunctionT = TypeVar("_FunctionT", bound=Callable[..., Any])
_P = ParamSpec("_P")
if sys.version_info < (3, 11):
@deprecated("Deprecated since Python 3.8; removed in Python 3.11. Use `async def` instead.")
def coroutine(func: _FunctionT) -> _FunctionT: ...
def iscoroutine(obj: object) -> TypeIs[Coroutine[Any, Any, Any]]: ...
if sys.version_info >= (3, 11):
@overload
@deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.")
def iscoroutinefunction(func: Callable[..., Coroutine[Any, Any, Any]]) -> bool: ...
@overload
@deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.")
def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, _T]]]: ...
@overload
@deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.")
def iscoroutinefunction(func: Callable[_P, object]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, Any]]]: ...
@overload
@deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.")
def iscoroutinefunction(func: object) -> TypeGuard[Callable[..., Coroutine[Any, Any, Any]]]: ...
else:
# Sometimes needed in Python < 3.11 due to the fact that it supports @coroutine
# which was removed in 3.11 which the inspect version doesn't support.
@overload
def iscoroutinefunction(func: Callable[..., Coroutine[Any, Any, Any]]) -> bool: ...
@overload
def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, _T]]]: ...
@overload
def iscoroutinefunction(func: Callable[_P, object]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, Any]]]: ...
@overload
def iscoroutinefunction(func: object) -> TypeGuard[Callable[..., Coroutine[Any, Any, Any]]]: ...