mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
Fix several methods that should be async def, but aren't (#7107)
This commit is contained in:
@@ -7,7 +7,7 @@ import ctypes
|
||||
import mmap
|
||||
import sys
|
||||
from os import PathLike
|
||||
from typing import AbstractSet, Any, Awaitable, Container, Generic, Iterable, Protocol, TypeVar, Union
|
||||
from typing import AbstractSet, Any, Container, Generic, Iterable, Protocol, TypeVar, Union
|
||||
from typing_extensions import Final, Literal, final
|
||||
|
||||
_KT = TypeVar("_KT")
|
||||
@@ -33,7 +33,7 @@ class SupportsNext(Protocol[_T_co]):
|
||||
|
||||
# stable
|
||||
class SupportsAnext(Protocol[_T_co]):
|
||||
def __anext__(self) -> Awaitable[_T_co]: ...
|
||||
async def __anext__(self) -> _T_co: ...
|
||||
|
||||
# Comparison protocols
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
from collections import deque
|
||||
from types import TracebackType
|
||||
from typing import Any, Awaitable, Callable, Generator, TypeVar
|
||||
from typing import Any, Callable, Generator, TypeVar
|
||||
|
||||
from .events import AbstractEventLoop
|
||||
from .futures import Future
|
||||
@@ -11,10 +11,10 @@ _T = TypeVar("_T")
|
||||
if sys.version_info >= (3, 9):
|
||||
class _ContextManagerMixin:
|
||||
def __init__(self, lock: Lock | Semaphore) -> None: ...
|
||||
def __aenter__(self) -> Awaitable[None]: ...
|
||||
def __aexit__(
|
||||
async def __aenter__(self) -> None: ...
|
||||
async def __aexit__(
|
||||
self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
|
||||
) -> Awaitable[None]: ...
|
||||
) -> None: ...
|
||||
|
||||
else:
|
||||
class _ContextManager:
|
||||
@@ -29,10 +29,10 @@ else:
|
||||
def __exit__(self, *args: Any) -> None: ...
|
||||
def __iter__(self) -> Generator[Any, None, _ContextManager]: ...
|
||||
def __await__(self) -> Generator[Any, None, _ContextManager]: ...
|
||||
def __aenter__(self) -> Awaitable[None]: ...
|
||||
def __aexit__(
|
||||
async def __aenter__(self) -> None: ...
|
||||
async def __aexit__(
|
||||
self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
|
||||
) -> Awaitable[None]: ...
|
||||
) -> None: ...
|
||||
|
||||
class Lock(_ContextManagerMixin):
|
||||
def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ...
|
||||
|
||||
@@ -85,7 +85,7 @@ class closing(AbstractContextManager[_SupportsCloseT]):
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
class _SupportsAclose(Protocol):
|
||||
def aclose(self) -> Awaitable[object]: ...
|
||||
async def aclose(self) -> object: ...
|
||||
_SupportsAcloseT = TypeVar("_SupportsAcloseT", bound=_SupportsAclose)
|
||||
|
||||
class aclosing(AbstractAsyncContextManager[_SupportsAcloseT]):
|
||||
@@ -122,7 +122,7 @@ if sys.version_info >= (3, 7):
|
||||
class AsyncExitStack(AbstractAsyncContextManager[AsyncExitStack]):
|
||||
def __init__(self) -> None: ...
|
||||
def enter_context(self, cm: AbstractContextManager[_T]) -> _T: ...
|
||||
def enter_async_context(self, cm: AbstractAsyncContextManager[_T]) -> Awaitable[_T]: ...
|
||||
async def enter_async_context(self, cm: AbstractAsyncContextManager[_T]) -> _T: ...
|
||||
def push(self, exit: _CM_EF) -> _CM_EF: ...
|
||||
def push_async_exit(self, exit: _ACM_EF) -> _ACM_EF: ...
|
||||
def callback(self, __callback: Callable[_P, _T], *args: _P.args, **kwds: _P.kwargs) -> Callable[_P, _T]: ...
|
||||
@@ -130,11 +130,11 @@ if sys.version_info >= (3, 7):
|
||||
self, __callback: Callable[_P, Awaitable[_T]], *args: _P.args, **kwds: _P.kwargs
|
||||
) -> Callable[_P, Awaitable[_T]]: ...
|
||||
def pop_all(self: Self) -> Self: ...
|
||||
def aclose(self) -> Awaitable[None]: ...
|
||||
def __aenter__(self: Self) -> Awaitable[Self]: ...
|
||||
def __aexit__(
|
||||
async def aclose(self) -> None: ...
|
||||
async def __aenter__(self: Self) -> Self: ...
|
||||
async def __aexit__(
|
||||
self, __exc_type: type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None
|
||||
) -> Awaitable[bool]: ...
|
||||
) -> bool: ...
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
class nullcontext(AbstractContextManager[_T], AbstractAsyncContextManager[_T]):
|
||||
|
||||
@@ -448,10 +448,10 @@ class ContextManager(Protocol[_T_co]):
|
||||
|
||||
@runtime_checkable
|
||||
class AsyncContextManager(Protocol[_T_co]):
|
||||
def __aenter__(self) -> Awaitable[_T_co]: ...
|
||||
def __aexit__(
|
||||
async def __aenter__(self) -> _T_co: ...
|
||||
async def __aexit__(
|
||||
self, __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None
|
||||
) -> Awaitable[bool | None]: ...
|
||||
) -> bool | None: ...
|
||||
|
||||
class Mapping(Collection[_KT], Generic[_KT, _VT_co]):
|
||||
# TODO: We wish the key type could also be covariant, but that doesn't work,
|
||||
|
||||
Reference in New Issue
Block a user