From bd50dacd769386fcb2657f011f0d7cb602181113 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Tue, 29 Jun 2021 16:35:44 +0100 Subject: [PATCH] add py3.10 async contextlib.nullcontext (#5711) --- stdlib/contextlib.pyi | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index abf3df6b2a0b..66e7262d3a03 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -112,7 +112,19 @@ if sys.version_info >= (3, 7): __traceback: Optional[TracebackType], ) -> Awaitable[bool]: ... -if sys.version_info >= (3, 7): +if sys.version_info >= (3, 10): + 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) -> 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 @@ -120,4 +132,4 @@ if sys.version_info >= (3, 7): @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: ...