File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ import sys
99# Aliased here for backwards compatibility; TODO eventually remove this
1010from typing import ContextManager as ContextManager
1111
12+ if sys .version_info >= (3 , 5 ):
13+ from typing import AsyncContextManager , AsyncIterator
14+
1215if sys .version_info >= (3 , 6 ):
1316 from typing import ContextManager as AbstractContextManager
1417
@@ -26,6 +29,9 @@ if sys.version_info >= (3, 2):
2629else :
2730 def contextmanager (func : Callable [..., Iterator [_T ]]) -> Callable [..., ContextManager [_T ]]: ...
2831
32+ if sys .version_info >= (3 , 7 ):
33+ def asynccontextmanager (func : Callable [..., AsyncIterator [_T ]]) -> Callable [..., AsyncContextManager [_T ]]: ...
34+
2935if sys .version_info < (3 ,):
3036 def nested (* mgr : ContextManager [Any ]) -> ContextManager [Iterable [Any ]]: ...
3137
Original file line number Diff line number Diff line change @@ -291,6 +291,13 @@ class ContextManager(Generic[_T_co]):
291291 exc_value : Optional [BaseException ],
292292 traceback : Optional [TracebackType ]) -> Optional [bool ]: ...
293293
294+ if sys .version_info >= (3 , 5 ):
295+ class AsyncContextManager (Generic [_T_co ]):
296+ def __aenter__ (self ) -> Awaitable [_T_co ]: ...
297+ def __aexit__ (self , exc_type : Optional [Type [BaseException ]],
298+ exc_value : Optional [BaseException ],
299+ traceback : Optional [TracebackType ]) -> Awaitable [Optional [bool ]]: ...
300+
294301class Mapping (_Collection [_KT ], Generic [_KT , _VT_co ]):
295302 # TODO: We wish the key type could also be covariant, but that doesn't work,
296303 # see discussion in https: //github.com/python/typing/pull/273.
You can’t perform that action at this time.
0 commit comments