File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import inspect
22import uuid
3+ from contextlib import _AsyncGeneratorContextManager , _GeneratorContextManager
34from typing import (
45 Any ,
5- AsyncContextManager ,
66 AsyncGenerator ,
77 Callable ,
8- ContextManager ,
98 Coroutine ,
109 Dict ,
1110 Generator ,
2120
2221@overload
2322def Depends (
24- dependency : Optional [Callable [..., ContextManager [_T ]]] = None ,
23+ dependency : Optional [Callable [..., "_GeneratorContextManager [_T]" ]] = None ,
2524 * ,
2625 use_cache : bool = True ,
2726 kwargs : Optional [Dict [str , Any ]] = None ,
@@ -31,7 +30,7 @@ def Depends(
3130
3231@overload
3332def Depends (
34- dependency : Optional [Callable [..., AsyncContextManager [_T ]]] = None ,
33+ dependency : Optional [Callable [..., "_AsyncGeneratorContextManager [_T]" ]] = None ,
3534 * ,
3635 use_cache : bool = True ,
3736 kwargs : Optional [Dict [str , Any ]] = None ,
Original file line number Diff line number Diff line change 11import inspect
22import sys
3- from contextlib import AsyncContextDecorator , ContextDecorator
3+ from contextlib import _AsyncGeneratorContextManager , _GeneratorContextManager
44from typing import Any , AsyncContextManager , ContextManager , Optional
55
66if sys .version_info >= (3 , 10 ):
@@ -39,7 +39,7 @@ def iscontextmanager(obj: Any) -> TypeGuard[ContextManager[Any]]:
3939 :param obj: object to check.
4040 :return: bool that indicates whether the object is a context manager or not.
4141 """
42- return issubclass (obj .__class__ , ContextDecorator )
42+ return issubclass (obj .__class__ , _GeneratorContextManager )
4343
4444
4545def isasynccontextmanager (obj : Any ) -> TypeGuard [AsyncContextManager [Any ]]:
@@ -49,4 +49,4 @@ def isasynccontextmanager(obj: Any) -> TypeGuard[AsyncContextManager[Any]]:
4949 :param obj: object to check.
5050 :return: bool that indicates whether the object is a async context manager or not.
5151 """
52- return issubclass (obj .__class__ , AsyncContextDecorator )
52+ return issubclass (obj .__class__ , _AsyncGeneratorContextManager )
You can’t perform that action at this time.
0 commit comments