diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index abf3df6b2..66e7262d3 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: ...