From bf2049ef18244b8b3024cd7a8cb28b7457dd4652 Mon Sep 17 00:00:00 2001 From: Aaron Kau Date: Wed, 9 Mar 2022 19:34:24 -0800 Subject: [PATCH] Change TemporaryFileWrapper.__exit__ return type to None (#7470) For context we found this from quora/pyanalyze#496, which makes pyanalyze stricter about context managers that may swallow exceptions. tempfile._TemporaryFileWrapper.__exit__ returns whatever its underlying file returns (https://github.com/python/cpython/blob/3.6/Lib/tempfile.py#L502), and file objects don't tend to return anything from __exit__. --- stdlib/tempfile.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index 3821c002c..fe8e3af2e 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -185,7 +185,7 @@ class _TemporaryFileWrapper(Generic[AnyStr], IO[AnyStr]): delete: bool def __init__(self, file: IO[AnyStr], name: str, delete: bool = ...) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, exc: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None) -> bool | None: ... + def __exit__(self, exc: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None) -> None: ... def __getattr__(self, name: str) -> Any: ... def close(self) -> None: ... # These methods don't exist directly on this object, but