mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
Sync asyncio.isfuture definitions by sharing asyncio.base_futures.isfuture definition (#7353)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import sys
|
||||
from typing import Any, Callable, Sequence
|
||||
from typing_extensions import Literal, TypeGuard
|
||||
from typing_extensions import Literal
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from contextvars import Context
|
||||
@@ -12,12 +12,15 @@ if sys.version_info >= (3, 7):
|
||||
else:
|
||||
__all__: list[str] = []
|
||||
|
||||
# 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.
|
||||
from .futures import isfuture as isfuture
|
||||
|
||||
_PENDING: Literal["PENDING"] # undocumented
|
||||
_CANCELLED: Literal["CANCELLED"] # undocumented
|
||||
_FINISHED: Literal["FINISHED"] # undocumented
|
||||
|
||||
def isfuture(obj: object) -> TypeGuard[futures.Future[Any]]: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
def _format_callbacks(cb: Sequence[tuple[Callable[[futures.Future[Any]], None], Context]]) -> str: ... # undocumented
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import sys
|
||||
from _typeshed import Self
|
||||
from concurrent.futures._base import Error, Future as _ConcurrentFuture
|
||||
from typing import Any, Awaitable, Callable, Generator, Iterable, TypeVar
|
||||
from typing_extensions import TypeGuard
|
||||
|
||||
from .events import AbstractEventLoop
|
||||
|
||||
@@ -25,6 +26,11 @@ else:
|
||||
|
||||
_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]]: ...
|
||||
|
||||
if sys.version_info < (3, 7):
|
||||
class _TracebackLogger:
|
||||
exc: BaseException
|
||||
@@ -34,8 +40,6 @@ if sys.version_info < (3, 7):
|
||||
def clear(self) -> None: ...
|
||||
def __del__(self) -> None: ...
|
||||
|
||||
def isfuture(obj: object) -> bool: ...
|
||||
|
||||
class Future(Awaitable[_T], Iterable[_T]):
|
||||
_state: str
|
||||
_exception: BaseException
|
||||
|
||||
Reference in New Issue
Block a user