From bbbccf61dc83f2b5e0a99703784ff297fcc2e76b Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 24 Nov 2015 21:08:02 -0800 Subject: [PATCH] Add 'closing' to 2.7 contextlib stubs (same as for 3). --- stdlib/2.7/contextlib.pyi | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/stdlib/2.7/contextlib.pyi b/stdlib/2.7/contextlib.pyi index cebbfb132..af9f0ab2a 100644 --- a/stdlib/2.7/contextlib.pyi +++ b/stdlib/2.7/contextlib.pyi @@ -2,7 +2,14 @@ # NOTE: These are incomplete! -from typing import Any +from typing import Any, TypeVar, Generic # TODO more precise type? def contextmanager(func: Any) -> Any: ... + +_T = TypeVar('_T') + +class closing(Generic[_T]): + def __init__(self, thing: _T) -> None: ... + def __enter__(self) -> _T: ... + def __exit__(self, *exc_info) -> None: ...