mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
Use TypeIs for asyncio function (#11847)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
from collections.abc import Awaitable, Callable, Coroutine
|
||||
from typing import Any, TypeVar, overload
|
||||
from typing_extensions import ParamSpec, TypeGuard
|
||||
from typing_extensions import ParamSpec, TypeGuard, TypeIs
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
__all__ = ("iscoroutinefunction", "iscoroutine")
|
||||
@@ -23,4 +23,4 @@ def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable
|
||||
def iscoroutinefunction(func: Callable[_P, object]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, Any]]]: ...
|
||||
@overload
|
||||
def iscoroutinefunction(func: object) -> TypeGuard[Callable[..., Coroutine[Any, Any, Any]]]: ...
|
||||
def iscoroutine(obj: object) -> TypeGuard[Coroutine[Any, Any, Any]]: ...
|
||||
def iscoroutine(obj: object) -> TypeIs[Coroutine[Any, Any, Any]]: ...
|
||||
|
||||
@@ -3,7 +3,7 @@ from collections.abc import Awaitable, Callable, Generator, Iterable
|
||||
from concurrent.futures._base import Future as _ConcurrentFuture
|
||||
from contextvars import Context
|
||||
from typing import Any, Literal, TypeVar
|
||||
from typing_extensions import Self, TypeGuard
|
||||
from typing_extensions import Self, TypeIs
|
||||
|
||||
from .events import AbstractEventLoop
|
||||
|
||||
@@ -17,7 +17,7 @@ _T = TypeVar("_T")
|
||||
# asyncio defines 'isfuture()' in base_futures.py and re-imports it in futures.py
|
||||
# but it leads to circular import error in pytype tool.
|
||||
# That's why the import order is reversed.
|
||||
def isfuture(obj: object) -> TypeGuard[Future[Any]]: ...
|
||||
def isfuture(obj: object) -> TypeIs[Future[Any]]: ...
|
||||
|
||||
class Future(Awaitable[_T], Iterable[_T]):
|
||||
_state: str
|
||||
|
||||
Reference in New Issue
Block a user