@@ -32,9 +32,9 @@ _T = TypeVar("_T")
32
32
_T_co = TypeVar ("_T_co" , covariant = True )
33
33
_T_io = TypeVar ("_T_io" , bound = IO [str ] | None )
34
34
_ExitT_co = TypeVar ("_ExitT_co" , covariant = True , bound = bool | None , default = bool | None )
35
- _F = TypeVar ("_F" , bound = Callable [..., Any ])
36
35
_G = TypeVar ("_G" , bound = Generator [Any , Any , Any ] | AsyncGenerator [Any , Any ], covariant = True )
37
36
_P = ParamSpec ("_P" )
37
+ _R = TypeVar ("_R" )
38
38
39
39
_SendT_contra = TypeVar ("_SendT_contra" , contravariant = True , default = None )
40
40
_ReturnT_co = TypeVar ("_ReturnT_co" , covariant = True , default = None )
@@ -64,9 +64,13 @@ class AbstractAsyncContextManager(ABC, Protocol[_T_co, _ExitT_co]): # type: ign
64
64
self , exc_type : type [BaseException ] | None , exc_value : BaseException | None , traceback : TracebackType | None , /
65
65
) -> _ExitT_co : ...
66
66
67
+ class _WrappedCallable (Generic [_P , _R ]):
68
+ __wrapped__ : Callable [_P , _R ]
69
+ def __call__ (self , * args : _P .args , ** kwargs : _P .kwargs ) -> _R : ...
70
+
67
71
class ContextDecorator :
68
72
def _recreate_cm (self ) -> Self : ...
69
- def __call__ (self , func : _F ) -> _F : ...
73
+ def __call__ (self , func : Callable [ _P , _R ] ) -> _WrappedCallable [ _P , _R ] : ...
70
74
71
75
class _GeneratorContextManagerBase (Generic [_G ]):
72
76
# Ideally this would use ParamSpec, but that requires (*args, **kwargs), which this isn't. see #6676
@@ -93,11 +97,11 @@ class _GeneratorContextManager(
93
97
def contextmanager (func : Callable [_P , Iterator [_T_co ]]) -> Callable [_P , _GeneratorContextManager [_T_co ]]: ...
94
98
95
99
if sys .version_info >= (3 , 10 ):
96
- _AF = TypeVar ("_AF " , bound = Callable [..., Awaitable [Any ] ])
100
+ _AR = TypeVar ("_AR " , bound = Awaitable [Any ])
97
101
98
102
class AsyncContextDecorator :
99
103
def _recreate_cm (self ) -> Self : ...
100
- def __call__ (self , func : _AF ) -> _AF : ...
104
+ def __call__ (self , func : Callable [ _P , _AR ] ) -> _WrappedCallable [ _P , _AR ] : ...
101
105
102
106
class _AsyncGeneratorContextManager (
103
107
_GeneratorContextManagerBase [AsyncGenerator [_T_co , _SendT_contra ]],
0 commit comments