@@ -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 ])
35
36
_G = TypeVar ("_G" , bound = Generator [Any , Any , Any ] | AsyncGenerator [Any , Any ], covariant = True )
36
37
_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,13 +64,9 @@ 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
-
71
67
class ContextDecorator :
72
68
def _recreate_cm (self ) -> Self : ...
73
- def __call__ (self , func : Callable [ _P , _R ] ) -> _WrappedCallable [ _P , _R ] : ...
69
+ def __call__ (self , func : _F ) -> _F : ...
74
70
75
71
class _GeneratorContextManagerBase (Generic [_G ]):
76
72
# Ideally this would use ParamSpec, but that requires (*args, **kwargs), which this isn't. see #6676
@@ -97,11 +93,11 @@ class _GeneratorContextManager(
97
93
def contextmanager (func : Callable [_P , Iterator [_T_co ]]) -> Callable [_P , _GeneratorContextManager [_T_co ]]: ...
98
94
99
95
if sys .version_info >= (3 , 10 ):
100
- _AR = TypeVar ("_AR " , bound = Awaitable [Any ])
96
+ _AF = TypeVar ("_AF " , bound = Callable [..., Awaitable [Any ] ])
101
97
102
98
class AsyncContextDecorator :
103
99
def _recreate_cm (self ) -> Self : ...
104
- def __call__ (self , func : Callable [ _P , _AR ] ) -> _WrappedCallable [ _P , _AR ] : ...
100
+ def __call__ (self , func : _AF ) -> _AF : ...
105
101
106
102
class _AsyncGeneratorContextManager (
107
103
_GeneratorContextManagerBase [AsyncGenerator [_T_co , _SendT_contra ]],
0 commit comments