@@ -141,6 +141,32 @@ reveal_type(whatever) # N: Revealed type is "def (x: builtins.int) -> builtins.
141141reveal_type(whatever(217)) # N: Revealed type is "builtins.list[builtins.int]"
142142[builtins fixtures/paramspec.pyi]
143143
144+ [case testParamSpecVariadicContextManager]
145+ from typing import Callable, Generic, TypeVar, TypeVarTuple, Unpack
146+ from typing_extensions import ParamSpec
147+
148+ P = ParamSpec("P")
149+ R = TypeVar("R")
150+ Ts = TypeVarTuple("Ts")
151+
152+ class contextmanager(Generic[P, R]):
153+ def __init__(self, func: Callable[P, R]) -> None: ...
154+
155+ def __call__(self, *args: P.args, **kwargs: P.kwargs) -> "_contextmanager_cls[P, R]": ...
156+
157+ class _contextmanager_cls(Generic[P, R]):
158+ def __enter__(self) -> R: ...
159+ def __exit__(self, *args: object) -> bool: ...
160+
161+ @contextmanager
162+ def print_args(*args: Unpack[Ts]) -> tuple[Unpack[Ts]]: ...
163+
164+ with print_args(2, "x") as value:
165+ reveal_type(value) # N: Revealed type is "tuple[builtins.int, builtins.str]"
166+
167+ reveal_type(print_args(2, "x")) # N: Revealed type is "__main__._contextmanager_cls[[Literal[2]?, Literal['x']?], tuple[Literal[2]?, Literal['x']?]]"
168+ [builtins fixtures/tuple.pyi]
169+
144170[case testInvalidParamSpecType]
145171from typing import ParamSpec
146172
0 commit comments