Skip to content

Commit

Permalink
add py3.10 async contextlib.nullcontext (#5711)
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert authored Jun 29, 2021
1 parent 389b92c commit bd50dac
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions stdlib/contextlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,24 @@ 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
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: ...

0 comments on commit bd50dac

Please sign in to comment.