Merge pull request #40 from graingert/widen-supports-aclose

sync pyi from typeshed
This commit is contained in:
Nick Coghlan 2021-06-30 22:24:55 +10:00 committed by GitHub
commit 2dc4c04492
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 9 deletions

View file

@ -57,7 +57,7 @@ class closing(ContextManager[_SupportsCloseT]):
if True:
class _SupportsAclose(Protocol):
async def aclose(self) -> object: ...
def aclose(self) -> Awaitable[object]: ...
_SupportsAcloseT = TypeVar("_SupportsAcloseT", bound=_SupportsAclose)
class aclosing(AsyncContextManager[_SupportsAcloseT]):
def __init__(self, thing: _SupportsAcloseT) -> None: ...
@ -121,12 +121,15 @@ if True:
__traceback: Optional[TracebackType],
) -> Awaitable[bool]: ...
if True:
class nullcontext(AbstractContextManager[_T]):
class nullcontext(AbstractContextManager[_T], AbstractAsyncContextManager[_T]):
enter_result: _T
@overload
def __init__(self: nullcontext[None], enter_result: None = ...) -> None: ...
@overload
def __init__(self: nullcontext[_T], enter_result: _T) -> None: ...
def __enter__(self) -> _T: ...
def __exit__(self, *exctype: Any) -> bool: ...
def __exit__(self, *exctype: Any) -> None: ...
async def __aenter__(self) -> _T: ...
async def __aexit__(self, *exctype: Any) -> None: ...

View file

@ -1,5 +1,5 @@
--- ../contextlib.pyi 2021-06-27 16:02:28.004872421 +1000
+++ contextlib2/__init__.pyi 2021-06-27 16:00:25.431733524 +1000
--- ../contextlib.pyi 2021-06-29 19:05:46.515307191 +0100
+++ contextlib2/__init__.pyi 2021-06-29 19:15:26.814620184 +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
@ -39,7 +39,7 @@
-if sys.version_info >= (3, 10):
+if True:
class _SupportsAclose(Protocol):
async def aclose(self) -> object: ...
def aclose(self) -> Awaitable[object]: ...
_SupportsAcloseT = TypeVar("_SupportsAcloseT", bound=_SupportsAclose)
@@ -88,7 +97,7 @@
__traceback: Optional[TracebackType],
@ -50,12 +50,27 @@
_S = TypeVar("_S", bound=AsyncExitStack)
_ExitCoroFunc = Callable[[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]], Awaitable[bool]]
@@ -112,7 +121,7 @@
@@ -112,7 +121,8 @@
__traceback: Optional[TracebackType],
) -> Awaitable[bool]: ...
-if sys.version_info >= (3, 7):
-if sys.version_info >= (3, 10):
+
+if True:
class nullcontext(AbstractContextManager[_T]):
class nullcontext(AbstractContextManager[_T], AbstractAsyncContextManager[_T]):
enter_result: _T
@overload
@@ -123,13 +133,3 @@
def __exit__(self, *exctype: Any) -> None: ...
async def __aenter__(self) -> _T: ...
async def __aexit__(self, *exctype: Any) -> None: ...
-
-elif sys.version_info >= (3, 7):
- class nullcontext(AbstractContextManager[_T]):
- enter_result: _T
- @overload
- def __init__(self: nullcontext[None], enter_result: None = ...) -> None: ...
- @overload
- def __init__(self: nullcontext[_T], enter_result: _T) -> None: ...
- def __enter__(self) -> _T: ...
- def __exit__(self, *exctype: Any) -> None: ...