Sync asyncio.isfuture definitions by sharing asyncio.base_futures.isfuture definition (#7353)

This commit is contained in:
Andrew Svetlov
2022-02-22 19:24:57 +02:00
committed by GitHub
parent a37d5f4849
commit 28fd555431
2 changed files with 12 additions and 5 deletions

View File

@@ -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