@@ -14,7 +14,7 @@ from typing import (
1414 TypeVar ,
1515 overload ,
1616)
17- from typing_extensions import Protocol
17+ from typing_extensions import ParamSpec , Protocol
1818
1919AbstractContextManager = ContextManager
2020if sys .version_info >= (3 , 7 ):
@@ -24,17 +24,19 @@ _T = TypeVar("_T")
2424_T_co = TypeVar ("_T_co" , covariant = True )
2525_T_io = TypeVar ("_T_io" , bound = Optional [IO [str ]])
2626_F = TypeVar ("_F" , bound = Callable [..., Any ])
27+ _P = ParamSpec ("_P" )
2728
2829_ExitFunc = Callable [[Optional [Type [BaseException ]], Optional [BaseException ], Optional [TracebackType ]], bool ]
2930_CM_EF = TypeVar ("_CM_EF" , ContextManager [Any ], _ExitFunc )
3031
3132class _GeneratorContextManager (ContextManager [_T_co ]):
3233 def __call__ (self , func : _F ) -> _F : ...
3334
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
3537
3638if 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
3840
3941class _SupportsClose (Protocol ):
4042 def close (self ) -> None : ...
0 commit comments