mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +08:00
add typing.AsyncContextManager and contextlib.asynccontextmanager (#1432)
Implements: - https://github.com/python/typing/pull/438 - https://github.com/python/cpython/pull/360 Note that https://github.com/python/cpython/pull/1412, which adds contextlib.AbstractAsyncContextManager, has not yet been merged.
This commit is contained in:
committed by
Guido van Rossum
parent
31d7393cae
commit
22f47fd478
@@ -9,6 +9,9 @@ import sys
|
||||
# Aliased here for backwards compatibility; TODO eventually remove this
|
||||
from typing import ContextManager as ContextManager
|
||||
|
||||
if sys.version_info >= (3, 5):
|
||||
from typing import AsyncContextManager, AsyncIterator
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
from typing import ContextManager as AbstractContextManager
|
||||
|
||||
@@ -26,6 +29,9 @@ if sys.version_info >= (3, 2):
|
||||
else:
|
||||
def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
def asynccontextmanager(func: Callable[..., AsyncIterator[_T]]) -> Callable[..., AsyncContextManager[_T]]: ...
|
||||
|
||||
if sys.version_info < (3,):
|
||||
def nested(*mgr: ContextManager[Any]) -> ContextManager[Iterable[Any]]: ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user