diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index 9088e86b7b4e..103af47c7524 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -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 diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index e9e8403716fb..ec959e89ba25 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -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: ... diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index 8853c12044e3..2ebf225f55f5 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -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]): diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 45819c811ed9..5a8557f909e5 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -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,