From 8b0e6b886d48c1bd38b125f2afd08b3fca51d0e0 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 13 Sep 2016 11:00:01 -0700 Subject: [PATCH] Fix signature for __exit__ (#542) --- stdlib/2.7/typing.pyi | 4 +++- stdlib/3/typing.pyi | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/stdlib/2.7/typing.pyi b/stdlib/2.7/typing.pyi index e8aa48a6f..a07558159 100644 --- a/stdlib/2.7/typing.pyi +++ b/stdlib/2.7/typing.pyi @@ -261,7 +261,9 @@ class IO(Iterator[AnyStr], Generic[AnyStr]): @abstractmethod def __enter__(self) -> 'IO[AnyStr]': ... @abstractmethod - def __exit__(self, t: type, value: Any, traceback: Any) -> bool: ... + def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException], + # TODO: traceback should be TracebackType but that's defined in types + traceback: Optional[Any]) -> bool: ... class BinaryIO(IO[str]): # TODO readinto diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index d5389962a..00d103666 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -319,7 +319,9 @@ class IO(Iterator[AnyStr], Generic[AnyStr]): @abstractmethod def __enter__(self) -> 'IO[AnyStr]': ... @abstractmethod - def __exit__(self, t: type = None, value: BaseException = None, traceback: Any = None) -> bool: ... + def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException], + # TODO: traceback should be TracebackType but that's defined in types + traceback: Optional[Any]) -> bool: ... class BinaryIO(IO[bytes]): # TODO readinto