From e7f731e74bded3efdd5c6967b0331d9428bbfda3 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 26 Nov 2015 21:02:23 -0800 Subject: [PATCH] Revert "Improve typing of 2.7/contextlib::contextmanager." This reverts commit 76c3a5bab0c0efc46a9879907ab481175e757328. --- stdlib/2.7/contextlib.pyi | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/stdlib/2.7/contextlib.pyi b/stdlib/2.7/contextlib.pyi index f9aa2945c..af9f0ab2a 100644 --- a/stdlib/2.7/contextlib.pyi +++ b/stdlib/2.7/contextlib.pyi @@ -2,16 +2,13 @@ # NOTE: These are incomplete! -from typing import Any, TypeVar, Callable, Generic, Iterator +from typing import Any, TypeVar, Generic + +# TODO more precise type? +def contextmanager(func: Any) -> Any: ... _T = TypeVar('_T') -class _GeneratorContextManager(Generic[_T]): - def __enter__(self) -> _T: ... - def __exit__(self, *exc_info) -> None: ... - -def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., _GeneratorContextManager[_T]]: ... - class closing(Generic[_T]): def __init__(self, thing: _T) -> None: ... def __enter__(self) -> _T: ...