mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 13:34:58 +08:00
add _asyncio (#12766)
improves naming and inheritance for asyncio.Future and asyncio.Task related to https://github.com/python/typeshed/issues/3968
This commit is contained in:
@@ -1,15 +1,10 @@
|
||||
import sys
|
||||
from collections.abc import Awaitable, Callable, Generator, Iterable
|
||||
from _asyncio import Future as Future
|
||||
from concurrent.futures._base import Future as _ConcurrentFuture
|
||||
from contextvars import Context
|
||||
from typing import Any, Literal, TypeVar
|
||||
from typing_extensions import Self, TypeIs
|
||||
from typing import Any, TypeVar
|
||||
from typing_extensions import TypeIs
|
||||
|
||||
from .events import AbstractEventLoop
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
__all__ = ("Future", "wrap_future", "isfuture")
|
||||
|
||||
_T = TypeVar("_T")
|
||||
@@ -18,40 +13,4 @@ _T = TypeVar("_T")
|
||||
# but it leads to circular import error in pytype tool.
|
||||
# That's why the import order is reversed.
|
||||
def isfuture(obj: object) -> TypeIs[Future[Any]]: ...
|
||||
|
||||
class Future(Awaitable[_T], Iterable[_T]):
|
||||
_state: str
|
||||
@property
|
||||
def _exception(self) -> BaseException | None: ...
|
||||
_blocking: bool
|
||||
@property
|
||||
def _log_traceback(self) -> bool: ...
|
||||
@_log_traceback.setter
|
||||
def _log_traceback(self, val: Literal[False]) -> None: ...
|
||||
_asyncio_future_blocking: bool # is a part of duck-typing contract for `Future`
|
||||
def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ...
|
||||
def __del__(self) -> None: ...
|
||||
def get_loop(self) -> AbstractEventLoop: ...
|
||||
@property
|
||||
def _callbacks(self) -> list[tuple[Callable[[Self], Any], Context]]: ...
|
||||
def add_done_callback(self, fn: Callable[[Self], object], /, *, context: Context | None = None) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def cancel(self, msg: Any | None = None) -> bool: ...
|
||||
else:
|
||||
def cancel(self) -> bool: ...
|
||||
|
||||
def cancelled(self) -> bool: ...
|
||||
def done(self) -> bool: ...
|
||||
def result(self) -> _T: ...
|
||||
def exception(self) -> BaseException | None: ...
|
||||
def remove_done_callback(self, fn: Callable[[Self], object], /) -> int: ...
|
||||
def set_result(self, result: _T, /) -> None: ...
|
||||
def set_exception(self, exception: type | BaseException, /) -> None: ...
|
||||
def __iter__(self) -> Generator[Any, None, _T]: ...
|
||||
def __await__(self) -> Generator[Any, None, _T]: ...
|
||||
@property
|
||||
def _loop(self) -> AbstractEventLoop: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
|
||||
|
||||
def wrap_future(future: _ConcurrentFuture[_T] | Future[_T], *, loop: AbstractEventLoop | None = None) -> Future[_T]: ...
|
||||
|
||||
Reference in New Issue
Block a user