resync from typeshed

This commit is contained in:
Thomas Grainger 2021-07-16 08:31:26 +01:00
parent 2dc4c04492
commit 16db3dcf86
No known key found for this signature in database
GPG key ID: E452A1247BAC1A88
2 changed files with 16 additions and 19 deletions

View file

@ -2,6 +2,7 @@
# https://github.com/python/typeshed/blob/64c85cdd449ccaff90b546676220c9ecfa6e697f/LICENSE
import sys
from _typeshed import Self
from types import TracebackType
from typing import (
IO,
@ -80,16 +81,14 @@ class redirect_stderr(ContextManager[_T_io]):
class ContextDecorator:
def __call__(self, func: _F) -> _F: ...
_U = TypeVar("_U", bound=ExitStack)
class ExitStack(ContextManager[ExitStack]):
def __init__(self) -> None: ...
def enter_context(self, cm: ContextManager[_T]) -> _T: ...
def push(self, exit: _CM_EF) -> _CM_EF: ...
def callback(self, callback: Callable[..., Any], *args: Any, **kwds: Any) -> Callable[..., Any]: ...
def pop_all(self: _U) -> _U: ...
def pop_all(self: Self) -> Self: ...
def close(self) -> None: ...
def __enter__(self: _U) -> _U: ...
def __enter__(self: Self) -> Self: ...
def __exit__(
self,
__exc_type: Optional[Type[BaseException]],
@ -98,8 +97,6 @@ class ExitStack(ContextManager[ExitStack]):
) -> bool: ...
if True:
_S = TypeVar("_S", bound=AsyncExitStack)
_ExitCoroFunc = Callable[[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]], Awaitable[bool]]
_CallbackCoroFunc = Callable[..., Awaitable[Any]]
_ACM_EF = TypeVar("_ACM_EF", AsyncContextManager[Any], _ExitCoroFunc)
@ -111,9 +108,9 @@ if True:
def push_async_exit(self, exit: _ACM_EF) -> _ACM_EF: ...
def callback(self, callback: Callable[..., Any], *args: Any, **kwds: Any) -> Callable[..., Any]: ...
def push_async_callback(self, callback: _CallbackCoroFunc, *args: Any, **kwds: Any) -> _CallbackCoroFunc: ...
def pop_all(self: _S) -> _S: ...
def pop_all(self: Self) -> Self: ...
def aclose(self) -> Awaitable[None]: ...
def __aenter__(self: _S) -> Awaitable[_S]: ...
def __aenter__(self: Self) -> Awaitable[Self]: ...
def __aexit__(
self,
__exc_type: Optional[Type[BaseException]],

View file

@ -1,13 +1,13 @@
--- ../contextlib.pyi 2021-06-29 19:05:46.515307191 +0100
+++ contextlib2/__init__.pyi 2021-06-29 19:15:26.814620184 +0100
--- ../contextlib.pyi 2021-07-16 08:26:16.409945194 +0100
+++ contextlib2/__init__.pyi 2021-07-16 08:32:00.363150171 +0100
@@ -1,3 +1,6 @@
+# Type hints copied from the typeshed project under the Apache License 2.0
+# https://github.com/python/typeshed/blob/64c85cdd449ccaff90b546676220c9ecfa6e697f/LICENSE
+
import sys
from _typeshed import Self
from types import TracebackType
from typing import (
@@ -16,8 +19,14 @@
@@ -17,8 +20,14 @@
)
from typing_extensions import ParamSpec, Protocol
@ -23,7 +23,7 @@
AbstractAsyncContextManager = AsyncContextManager
_T = TypeVar("_T")
@@ -35,7 +44,7 @@
@@ -36,7 +45,7 @@
# type ignore to deal with incomplete ParamSpec support in mypy
def contextmanager(func: Callable[_P, Iterator[_T]]) -> Callable[_P, _GeneratorContextManager[_T]]: ... # type: ignore
@ -32,7 +32,7 @@
def asynccontextmanager(func: Callable[_P, AsyncIterator[_T]]) -> Callable[_P, AsyncContextManager[_T]]: ... # type: ignore
class _SupportsClose(Protocol):
@@ -46,7 +55,7 @@
@@ -47,7 +56,7 @@
class closing(ContextManager[_SupportsCloseT]):
def __init__(self, thing: _SupportsCloseT) -> None: ...
@ -41,16 +41,16 @@
class _SupportsAclose(Protocol):
def aclose(self) -> Awaitable[object]: ...
_SupportsAcloseT = TypeVar("_SupportsAcloseT", bound=_SupportsAclose)
@@ -88,7 +97,7 @@
@@ -87,7 +96,7 @@
__traceback: Optional[TracebackType],
) -> bool: ...
-if sys.version_info >= (3, 7):
+if True:
_S = TypeVar("_S", bound=AsyncExitStack)
_ExitCoroFunc = Callable[[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]], Awaitable[bool]]
@@ -112,7 +121,8 @@
_CallbackCoroFunc = Callable[..., Awaitable[Any]]
_ACM_EF = TypeVar("_ACM_EF", AsyncContextManager[Any], _ExitCoroFunc)
@@ -109,7 +118,8 @@
__traceback: Optional[TracebackType],
) -> Awaitable[bool]: ...
@ -60,7 +60,7 @@
class nullcontext(AbstractContextManager[_T], AbstractAsyncContextManager[_T]):
enter_result: _T
@overload
@@ -123,13 +133,3 @@
@@ -120,13 +130,3 @@
def __exit__(self, *exctype: Any) -> None: ...
async def __aenter__(self) -> _T: ...
async def __aexit__(self, *exctype: Any) -> None: ...