add py3.10 async contextlib.nullcontext (#5711)

This commit is contained in:
Thomas Grainger
2021-06-29 16:35:44 +01:00
committed by GitHub
parent 389b92cb04
commit bd50dacd76

View File

@@ -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: ...