Skip to content

Commit b294782

Browse files
Michael0x2aJelleZijlstra
authored andcommitted
Make most contextmanager __exit__ signatures return Optional[bool] (#3179)
This pull request is a follow-up to python/mypy#7214. In short, within that mypy issue, we found it would be helpful to determine between contextmanagers that can "swallow" exceptions vs ones that can't. This helps prevent some false positive when using flags that analyze control flow such as `--warn-unreachable`. To do this, Jelle proposed assuming that only contextmanagers where the `__exit__` returns `bool` are assumed to swallow exceptions. This unfortunately required the following typeshed changes: 1. The typing.IO, threading.Lock, and concurrent.futures.Executor were all modified so `__exit__` returns `Optional[None]` instead of None -- along with all of their subclasses. I believe these three types are meant to be subclassed, so I felt picking the more general type was correct. 2. There were also a few concrete types (e.g. see socketserver, subprocess, ftplib...) that I modified to return `None` -- I checked the source code, and these all seem to return None (and don't appear to be meant to be subclassable). 3. contextlib.suppress was changed to return bool. I also double-checked the unittest modules and modified a subset of those contextmanagers, leaving ones like `_AssertRaisesContext` alone.
1 parent 3cfc315 commit b294782

25 files changed

+55
-38
lines changed

CONTRIBUTING.md

+9
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,15 @@ Type variables and aliases you introduce purely for legibility reasons
292292
should be prefixed with an underscore to make it obvious to the reader
293293
they are not part of the stubbed API.
294294

295+
When adding type annotations for context manager classes, annotate
296+
the return type of `__exit__` as bool only if the context manager
297+
sometimes suppresses annotations -- if it sometimes returns `True`
298+
at runtime. If the context manager never suppresses exceptions,
299+
have the return type be either `None` or `Optional[bool]`. If you
300+
are not sure whether exceptions are suppressed or not or if the
301+
context manager is meant to be subclassed, pick `Optional[bool]`.
302+
See https://github.com/python/mypy/issues/7214 for more details.
303+
295304
NOTE: there are stubs in this repository that don't conform to the
296305
style described above. Fixing them is a great starting point for new
297306
contributors.

stdlib/2/SocketServer.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class BaseServer:
3838
def __enter__(self) -> BaseServer: ...
3939
def __exit__(self, exc_type: Optional[Type[BaseException]],
4040
exc_val: Optional[BaseException],
41-
exc_tb: Optional[types.TracebackType]) -> bool: ...
41+
exc_tb: Optional[types.TracebackType]) -> None: ...
4242
if sys.version_info >= (3, 3):
4343
def service_actions(self) -> None: ...
4444

stdlib/2/__builtin__.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ class memoryview(Sized, Container[_mv_container_type]):
787787
nbytes: int
788788
def __init__(self, obj: Union[bytes, bytearray, memoryview]) -> None: ...
789789
def __enter__(self) -> memoryview: ...
790-
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> bool: ...
790+
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> None: ...
791791
else:
792792
def __init__(self, obj: Union[bytes, bytearray, buffer, memoryview]) -> None: ...
793793

@@ -1615,7 +1615,7 @@ if sys.version_info < (3,):
16151615
def next(self) -> str: ...
16161616
def read(self, n: int = ...) -> str: ...
16171617
def __enter__(self) -> BinaryIO: ...
1618-
def __exit__(self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ...) -> bool: ...
1618+
def __exit__(self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ...) -> Optional[bool]: ...
16191619
def flush(self) -> None: ...
16201620
def fileno(self) -> int: ...
16211621
def isatty(self) -> bool: ...

stdlib/2/_io.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class _IOBase(BinaryIO):
3232
def truncate(self, size: Optional[int] = ...) -> int: ...
3333
def writable(self) -> bool: ...
3434
def __enter__(self: _T) -> _T: ...
35-
def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any]) -> bool: ...
35+
def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any]) -> Optional[bool]: ...
3636
def __iter__(self: _T) -> _T: ...
3737
# The parameter type of writelines[s]() is determined by that of write():
3838
def writelines(self, lines: Iterable[bytes]) -> None: ...
@@ -146,7 +146,7 @@ class _TextIOBase(TextIO):
146146
def write(self, pbuf: unicode) -> int: ...
147147
def writelines(self, lines: Iterable[unicode]) -> None: ...
148148
def __enter__(self: _T) -> _T: ...
149-
def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any]) -> bool: ...
149+
def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any]) -> Optional[bool]: ...
150150
def __iter__(self: _T) -> _T: ...
151151

152152
class StringIO(_TextIOBase):

stdlib/2/subprocess.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Popen(Generic[_T]):
106106
def terminate(self) -> None: ...
107107
def kill(self) -> None: ...
108108
def __enter__(self) -> Popen: ...
109-
def __exit__(self, type, value, traceback) -> bool: ...
109+
def __exit__(self, type, value, traceback) -> None: ...
110110

111111
def list2cmdline(seq: Sequence[str]) -> str: ... # undocumented
112112

stdlib/2/tempfile.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class _TemporaryFileWrapper(IO[str]):
2424
def __init__(self, file: IO, name: Any, delete: bool = ...) -> None: ...
2525
def __del__(self) -> None: ...
2626
def __enter__(self) -> _TemporaryFileWrapper: ...
27-
def __exit__(self, exc, value, tb) -> bool: ...
27+
def __exit__(self, exc, value, tb) -> Optional[bool]: ...
2828
def __getattr__(self, name: unicode) -> Any: ...
2929
def close(self) -> None: ...
3030
def unlink(self, path: unicode) -> None: ...
@@ -88,7 +88,7 @@ class TemporaryDirectory:
8888
dir: Union[bytes, unicode] = ...) -> None: ...
8989
def cleanup(self) -> None: ...
9090
def __enter__(self) -> Any: ... # Can be str or unicode
91-
def __exit__(self, type, value, traceback) -> bool: ...
91+
def __exit__(self, type, value, traceback) -> None: ...
9292

9393
@overload
9494
def mkstemp() -> Tuple[int, str]: ...

stdlib/2/typing.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ class IO(Iterator[AnyStr], Generic[AnyStr]):
343343
def __enter__(self) -> IO[AnyStr]: ...
344344
@abstractmethod
345345
def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException],
346-
traceback: Optional[TracebackType]) -> bool: ...
346+
traceback: Optional[TracebackType]) -> Optional[bool]: ...
347347

348348
class BinaryIO(IO[str]):
349349
# TODO readinto

stdlib/2and3/builtins.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ class memoryview(Sized, Container[_mv_container_type]):
787787
nbytes: int
788788
def __init__(self, obj: Union[bytes, bytearray, memoryview]) -> None: ...
789789
def __enter__(self) -> memoryview: ...
790-
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> bool: ...
790+
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> None: ...
791791
else:
792792
def __init__(self, obj: Union[bytes, bytearray, buffer, memoryview]) -> None: ...
793793

@@ -1615,7 +1615,7 @@ if sys.version_info < (3,):
16151615
def next(self) -> str: ...
16161616
def read(self, n: int = ...) -> str: ...
16171617
def __enter__(self) -> BinaryIO: ...
1618-
def __exit__(self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ...) -> bool: ...
1618+
def __exit__(self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ...) -> Optional[bool]: ...
16191619
def flush(self) -> None: ...
16201620
def fileno(self) -> int: ...
16211621
def isatty(self) -> bool: ...

stdlib/2and3/codecs.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class StreamReaderWriter(TextIO):
188188
def __enter__(self: _T) -> _T: ...
189189
def __exit__(
190190
self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType]
191-
) -> bool: ...
191+
) -> None: ...
192192
def __getattr__(self, name: str) -> Any: ...
193193
# These methods don't actually exist directly, but they are needed to satisfy the TextIO
194194
# interface. At runtime, they are delegated through __getattr__.
@@ -229,7 +229,7 @@ class StreamRecoder(BinaryIO):
229229
def __enter__(self: _SRT) -> _SRT: ...
230230
def __exit__(
231231
self, type: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType]
232-
) -> bool: ...
232+
) -> None: ...
233233
# These methods don't actually exist directly, but they are needed to satisfy the BinaryIO
234234
# interface. At runtime, they are delegated through __getattr__.
235235
def seek(self, offset: int, whence: int = ...) -> int: ...

stdlib/2and3/contextlib.pyi

+9
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class closing(ContextManager[_T], Generic[_T]):
4646
if sys.version_info >= (3, 4):
4747
class suppress(ContextManager[None]):
4848
def __init__(self, *exceptions: Type[BaseException]) -> None: ...
49+
def __exit__(self, exctype: Optional[Type[BaseException]],
50+
excinst: Optional[BaseException],
51+
exctb: Optional[TracebackType]) -> bool: ...
4952

5053
class redirect_stdout(ContextManager[None]):
5154
def __init__(self, new_target: IO[str]) -> None: ...
@@ -69,6 +72,9 @@ if sys.version_info >= (3,):
6972
def pop_all(self: _U) -> _U: ...
7073
def close(self) -> None: ...
7174
def __enter__(self: _U) -> _U: ...
75+
def __exit__(self, __exc_type: Optional[Type[BaseException]],
76+
__exc_value: Optional[BaseException],
77+
__traceback: Optional[TracebackType]) -> bool: ...
7278

7379
if sys.version_info >= (3, 7):
7480
from typing import Awaitable
@@ -94,6 +100,9 @@ if sys.version_info >= (3, 7):
94100
def pop_all(self: _S) -> _S: ...
95101
def aclose(self) -> Awaitable[None]: ...
96102
def __aenter__(self: _S) -> Awaitable[_S]: ...
103+
def __aexit__(self, __exc_type: Optional[Type[BaseException]],
104+
__exc_value: Optional[BaseException],
105+
__traceback: Optional[TracebackType]) -> Awaitable[bool]: ...
97106

98107
if sys.version_info >= (3, 7):
99108
@overload

stdlib/2and3/ftplib.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class FTP:
4444
encoding: str
4545
def __enter__(self: _T) -> _T: ...
4646
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException],
47-
exc_tb: Optional[TracebackType]) -> bool: ...
47+
exc_tb: Optional[TracebackType]) -> None: ...
4848
else:
4949
file: Optional[BinaryIO]
5050

stdlib/2and3/tarfile.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class TarFile(Iterable[TarInfo]):
7777
def __exit__(self,
7878
exc_type: Optional[Type[BaseException]],
7979
exc_val: Optional[BaseException],
80-
exc_tb: Optional[TracebackType]) -> bool: ...
80+
exc_tb: Optional[TracebackType]) -> None: ...
8181
def __iter__(self) -> Iterator[TarInfo]: ...
8282
@classmethod
8383
def open(cls, name: Optional[_Path] = ..., mode: str = ...,

stdlib/2and3/threading.pyi

+5-5
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class Lock:
8181
def __enter__(self) -> bool: ...
8282
def __exit__(self, exc_type: Optional[Type[BaseException]],
8383
exc_val: Optional[BaseException],
84-
exc_tb: Optional[TracebackType]) -> bool: ...
84+
exc_tb: Optional[TracebackType]) -> Optional[bool]: ...
8585
if sys.version_info >= (3,):
8686
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
8787
else:
@@ -95,7 +95,7 @@ class _RLock:
9595
def __enter__(self) -> bool: ...
9696
def __exit__(self, exc_type: Optional[Type[BaseException]],
9797
exc_val: Optional[BaseException],
98-
exc_tb: Optional[TracebackType]) -> bool: ...
98+
exc_tb: Optional[TracebackType]) -> Optional[bool]: ...
9999
if sys.version_info >= (3,):
100100
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
101101
else:
@@ -111,7 +111,7 @@ class Condition:
111111
def __enter__(self) -> bool: ...
112112
def __exit__(self, exc_type: Optional[Type[BaseException]],
113113
exc_val: Optional[BaseException],
114-
exc_tb: Optional[TracebackType]) -> bool: ...
114+
exc_tb: Optional[TracebackType]) -> Optional[bool]: ...
115115
if sys.version_info >= (3,):
116116
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
117117
else:
@@ -131,7 +131,7 @@ class Semaphore:
131131
def __enter__(self) -> bool: ...
132132
def __exit__(self, exc_type: Optional[Type[BaseException]],
133133
exc_val: Optional[BaseException],
134-
exc_tb: Optional[TracebackType]) -> bool: ...
134+
exc_tb: Optional[TracebackType]) -> Optional[bool]: ...
135135
if sys.version_info >= (3,):
136136
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
137137
else:
@@ -143,7 +143,7 @@ class BoundedSemaphore:
143143
def __enter__(self) -> bool: ...
144144
def __exit__(self, exc_type: Optional[Type[BaseException]],
145145
exc_val: Optional[BaseException],
146-
exc_tb: Optional[TracebackType]) -> bool: ...
146+
exc_tb: Optional[TracebackType]) -> Optional[bool]: ...
147147
if sys.version_info >= (3,):
148148
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
149149
else:

stdlib/2and3/warnings.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ class catch_warnings:
4343
def __enter__(self) -> Optional[List[_Record]]: ...
4444
def __exit__(self, exc_type: Optional[Type[BaseException]],
4545
exc_val: Optional[BaseException],
46-
exc_tb: Optional[TracebackType]) -> bool: ...
46+
exc_tb: Optional[TracebackType]) -> None: ...

stdlib/2and3/zipfile.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class ZipFile:
5555
def __enter__(self) -> ZipFile: ...
5656
def __exit__(self, exc_type: Optional[Type[BaseException]],
5757
exc_val: Optional[BaseException],
58-
exc_tb: Optional[TracebackType]) -> bool: ...
58+
exc_tb: Optional[TracebackType]) -> None: ...
5959
def close(self) -> None: ...
6060
def getinfo(self, name: Text) -> ZipInfo: ...
6161
def infolist(self) -> List[ZipInfo]: ...

stdlib/3/concurrent/futures/_base.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Executor:
5353
def map(self, func: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ...,) -> Iterator[_T]: ...
5454
def shutdown(self, wait: bool = ...) -> None: ...
5555
def __enter__(self: _T) -> _T: ...
56-
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool: ...
56+
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> Optional[bool]: ...
5757

5858
def as_completed(fs: Iterable[Future[_T]], timeout: Optional[float] = ...) -> Iterator[Future[_T]]: ...
5959

stdlib/3/http/client.pyi

+2-3
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ responses: Dict[int, str]
8080

8181
class HTTPMessage(email.message.Message): ...
8282

83-
# Ignore errors to work around python/mypy#5027
84-
class HTTPResponse(io.BufferedIOBase, BinaryIO): # type: ignore
83+
class HTTPResponse(io.BufferedIOBase, BinaryIO):
8584
msg: HTTPMessage
8685
headers: HTTPMessage
8786
version: int
@@ -103,7 +102,7 @@ class HTTPResponse(io.BufferedIOBase, BinaryIO): # type: ignore
103102
def __enter__(self) -> HTTPResponse: ...
104103
def __exit__(self, exc_type: Optional[Type[BaseException]],
105104
exc_val: Optional[BaseException],
106-
exc_tb: Optional[types.TracebackType]) -> bool: ...
105+
exc_tb: Optional[types.TracebackType]) -> Optional[bool]: ...
107106
def info(self) -> email.message.Message: ...
108107
def geturl(self) -> str: ...
109108
def getcode(self) -> int: ...

stdlib/3/io.pyi

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class IOBase:
2828
def __next__(self) -> bytes: ...
2929
def __enter__(self: _T) -> _T: ...
3030
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException],
31-
exc_tb: Optional[TracebackType]) -> bool: ...
31+
exc_tb: Optional[TracebackType]) -> Optional[bool]: ...
3232
def close(self) -> None: ...
3333
def fileno(self) -> int: ...
3434
def flush(self) -> None: ...
@@ -86,7 +86,7 @@ class BytesIO(BinaryIO):
8686
def __next__(self) -> bytes: ...
8787
def __enter__(self) -> BytesIO: ...
8888
def __exit__(self, t: Optional[Type[BaseException]] = ..., value: Optional[BaseException] = ...,
89-
traceback: Optional[TracebackType] = ...) -> bool: ...
89+
traceback: Optional[TracebackType] = ...) -> Optional[bool]: ...
9090
def close(self) -> None: ...
9191
def fileno(self) -> int: ...
9292
def flush(self) -> None: ...
@@ -165,7 +165,7 @@ class TextIOWrapper(TextIO):
165165
) -> None: ...
166166
# copied from IOBase
167167
def __exit__(self, t: Optional[Type[BaseException]] = ..., value: Optional[BaseException] = ...,
168-
traceback: Optional[TracebackType] = ...) -> bool: ...
168+
traceback: Optional[TracebackType] = ...) -> Optional[bool]: ...
169169
def close(self) -> None: ...
170170
def fileno(self) -> int: ...
171171
def flush(self) -> None: ...

stdlib/3/socketserver.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class BaseServer:
3838
def __enter__(self) -> BaseServer: ...
3939
def __exit__(self, exc_type: Optional[Type[BaseException]],
4040
exc_val: Optional[BaseException],
41-
exc_tb: Optional[types.TracebackType]) -> bool: ...
41+
exc_tb: Optional[types.TracebackType]) -> None: ...
4242
if sys.version_info >= (3, 3):
4343
def service_actions(self) -> None: ...
4444

stdlib/3/subprocess.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ class Popen(Generic[AnyStr]):
11701170
def terminate(self) -> None: ...
11711171
def kill(self) -> None: ...
11721172
def __enter__(self) -> Popen: ...
1173-
def __exit__(self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]) -> bool: ...
1173+
def __exit__(self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]) -> None: ...
11741174

11751175
# The result really is always a str.
11761176
def getstatusoutput(cmd: _TXT) -> Tuple[int, str]: ...

stdlib/3/tempfile.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class SpooledTemporaryFile(IO[AnyStr]):
3838
def __enter__(self) -> SpooledTemporaryFile: ...
3939
def __exit__(self, exc_type: Optional[Type[BaseException]],
4040
exc_val: Optional[BaseException],
41-
exc_tb: Optional[TracebackType]) -> bool: ...
41+
exc_tb: Optional[TracebackType]) -> Optional[bool]: ...
4242

4343
# These methods are copied from the abstract methods of IO, because
4444
# SpooledTemporaryFile implements IO.
@@ -69,7 +69,7 @@ class TemporaryDirectory(Generic[AnyStr]):
6969
def __enter__(self) -> AnyStr: ...
7070
def __exit__(self, exc_type: Optional[Type[BaseException]],
7171
exc_val: Optional[BaseException],
72-
exc_tb: Optional[TracebackType]) -> bool: ...
72+
exc_tb: Optional[TracebackType]) -> None: ...
7373

7474
def mkstemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[AnyStr] = ...,
7575
text: bool = ...) -> Tuple[int, AnyStr]: ...

stdlib/3/typing.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ class IO(Iterator[AnyStr], Generic[AnyStr]):
479479
def __enter__(self) -> IO[AnyStr]: ...
480480
@abstractmethod
481481
def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException],
482-
traceback: Optional[TracebackType]) -> bool: ...
482+
traceback: Optional[TracebackType]) -> Optional[bool]: ...
483483

484484
class BinaryIO(IO[bytes]):
485485
# TODO readinto

stdlib/3/unittest/case.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ class _AssertWarnsContext:
214214
lineno: int
215215
def __enter__(self) -> _AssertWarnsContext: ...
216216
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException],
217-
exc_tb: Optional[TracebackType]) -> bool: ...
217+
exc_tb: Optional[TracebackType]) -> None: ...
218218

219219
class _AssertLogsContext:
220220
records: List[logging.LogRecord]
221221
output: List[str]
222222
def __enter__(self) -> _AssertLogsContext: ...
223223
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException],
224-
exc_tb: Optional[TracebackType]) -> bool: ...
224+
exc_tb: Optional[TracebackType]) -> Optional[bool]: ...

stdlib/3/urllib/response.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ _AIUT = TypeVar("_AIUT", bound=addbase)
77

88
class addbase(BinaryIO):
99
def __enter__(self: _AIUT) -> _AIUT: ...
10-
def __exit__(self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]) -> bool: ...
10+
def __exit__(self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]) -> None: ...
1111
def __iter__(self: _AIUT) -> _AIUT: ...
1212
def __next__(self) -> bytes: ...
1313
def close(self) -> None: ...

third_party/2/concurrent/futures/_base.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Executor:
5353
def map(self, func: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ...,) -> Iterator[_T]: ...
5454
def shutdown(self, wait: bool = ...) -> None: ...
5555
def __enter__(self: _T) -> _T: ...
56-
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool: ...
56+
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> Optional[bool]: ...
5757

5858
def as_completed(fs: Iterable[Future[_T]], timeout: Optional[float] = ...) -> Iterator[Future[_T]]: ...
5959

0 commit comments

Comments
 (0)