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.
This commit is contained in:
Alex Waygood
2022-01-27 15:35:19 +00:00
committed by GitHub
parent e01fc81497
commit 5b39d07cd9

View File

@@ -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]]: ...