File tree 2 files changed +13
-0
lines changed
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ import sys
9
9
# Aliased here for backwards compatibility; TODO eventually remove this
10
10
from typing import ContextManager as ContextManager
11
11
12
+ if sys .version_info >= (3 , 5 ):
13
+ from typing import AsyncContextManager , AsyncIterator
14
+
12
15
if sys .version_info >= (3 , 6 ):
13
16
from typing import ContextManager as AbstractContextManager
14
17
@@ -26,6 +29,9 @@ if sys.version_info >= (3, 2):
26
29
else :
27
30
def contextmanager (func : Callable [..., Iterator [_T ]]) -> Callable [..., ContextManager [_T ]]: ...
28
31
32
+ if sys .version_info >= (3 , 7 ):
33
+ def asynccontextmanager (func : Callable [..., AsyncIterator [_T ]]) -> Callable [..., AsyncContextManager [_T ]]: ...
34
+
29
35
if sys .version_info < (3 ,):
30
36
def nested (* mgr : ContextManager [Any ]) -> ContextManager [Iterable [Any ]]: ...
31
37
Original file line number Diff line number Diff line change @@ -291,6 +291,13 @@ class ContextManager(Generic[_T_co]):
291
291
exc_value : Optional [BaseException ],
292
292
traceback : Optional [TracebackType ]) -> Optional [bool ]: ...
293
293
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
+
294
301
class Mapping (_Collection [_KT ], Generic [_KT , _VT_co ]):
295
302
# TODO: We wish the key type could also be covariant, but that doesn't work,
296
303
# see discussion in https: //github.com/python/typing/pull/273.
You can’t perform that action at this time.
0 commit comments