From 5b39d07cd9d75a5342d0fe0b9eadf7d38f80ab12 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 27 Jan 2022 15:35:19 +0000 Subject: [PATCH] Add `ParamSpec` to `decorator.contextmanager` (#7051) There may be other places in this package where `ParamSpec` could be used, but this one is the most clear-cut. --- stubs/decorator/decorator.pyi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stubs/decorator/decorator.pyi b/stubs/decorator/decorator.pyi index 5fa6a275f..c2a4bed79 100644 --- a/stubs/decorator/decorator.pyi +++ b/stubs/decorator/decorator.pyi @@ -1,9 +1,11 @@ import sys from typing import Any, Callable, Iterator, NamedTuple, Pattern, Text, TypeVar +from typing_extensions import ParamSpec _C = TypeVar("_C", bound=Callable[..., Any]) _Func = TypeVar("_Func", bound=Callable[..., Any]) _T = TypeVar("_T") +_P = ParamSpec("_P") def get_init(cls: type) -> None: ... @@ -79,5 +81,5 @@ def decorator( class ContextManager(_GeneratorContextManager[_T]): def __call__(self, func: _C) -> _C: ... -def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ... +def contextmanager(func: Callable[_P, Iterator[_T]]) -> Callable[_P, ContextManager[_T]]: ... def dispatch_on(*dispatch_args: Any) -> Callable[[Callable[..., Any]], Callable[..., Any]]: ...