From 0914d50b498c38dfc86337f40d4327592aded8a8 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Wed, 9 Oct 2019 15:58:37 +0100 Subject: [PATCH] Fix the signature of decorator.contextmanager (#3330) --- third_party/2and3/decorator.pyi | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/third_party/2and3/decorator.pyi b/third_party/2and3/decorator.pyi index 18c919f87..ee090a6b9 100644 --- a/third_party/2and3/decorator.pyi +++ b/third_party/2and3/decorator.pyi @@ -1,8 +1,9 @@ import sys -from typing import Any, Callable, Dict, List, NamedTuple, Optional, Pattern, Text, Tuple, TypeVar +from typing import Any, Callable, Dict, Iterator, List, NamedTuple, Optional, Pattern, Text, Tuple, TypeVar _C = TypeVar("_C", bound=Callable[..., Any]) _Func = TypeVar("_Func", bound=Callable[..., Any]) +_T = TypeVar("_T") def get_init(cls): ... @@ -76,8 +77,8 @@ class FunctionMaker(object): def decorate(func: _Func, caller: Callable[..., Any], extras: Any = ...) -> _Func: ... def decorator(caller: Callable[..., Any], _func: Optional[Callable[..., Any]] = ...) -> Callable[[_C], _C]: ... -class ContextManager(_GeneratorContextManager[Any]): +class ContextManager(_GeneratorContextManager[_T]): def __call__(self, func: _C) -> _C: ... -def contextmanager(func: _C) -> _C: ... +def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ... def dispatch_on(*dispatch_args: Any) -> Callable[[Callable[..., Any]], Callable[..., Any]]: ...