@@ -14,7 +14,7 @@ from typing import (
14
14
TypeVar ,
15
15
overload ,
16
16
)
17
- from typing_extensions import Protocol
17
+ from typing_extensions import ParamSpec , Protocol
18
18
19
19
AbstractContextManager = ContextManager
20
20
if sys .version_info >= (3 , 7 ):
@@ -24,17 +24,19 @@ _T = TypeVar("_T")
24
24
_T_co = TypeVar ("_T_co" , covariant = True )
25
25
_T_io = TypeVar ("_T_io" , bound = Optional [IO [str ]])
26
26
_F = TypeVar ("_F" , bound = Callable [..., Any ])
27
+ _P = ParamSpec ("_P" )
27
28
28
29
_ExitFunc = Callable [[Optional [Type [BaseException ]], Optional [BaseException ], Optional [TracebackType ]], bool ]
29
30
_CM_EF = TypeVar ("_CM_EF" , ContextManager [Any ], _ExitFunc )
30
31
31
32
class _GeneratorContextManager (ContextManager [_T_co ]):
32
33
def __call__ (self , func : _F ) -> _F : ...
33
34
34
- def contextmanager (func : Callable [..., Iterator [_T ]]) -> Callable [..., _GeneratorContextManager [_T ]]: ...
35
+ # type ignore to deal with incomplete ParamSpec support in mypy
36
+ def contextmanager (func : Callable [_P , Iterator [_T ]]) -> Callable [_P , _GeneratorContextManager [_T ]]: ... # type: ignore
35
37
36
38
if sys .version_info >= (3 , 7 ):
37
- def asynccontextmanager (func : Callable [... , AsyncIterator [_T ]]) -> Callable [... , AsyncContextManager [_T ]]: ...
39
+ def asynccontextmanager (func : Callable [_P , AsyncIterator [_T ]]) -> Callable [_P , AsyncContextManager [_T ]]: ... # type: ignore
38
40
39
41
class _SupportsClose (Protocol ):
40
42
def close (self ) -> None : ...
0 commit comments