Skip to content

Commit 1600850

Browse files
authored
fix inheritance for urllib.response.addbase (#11152)
1 parent cff2b3d commit 1600850

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

stdlib/urllib/response.pyi

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,23 @@
11
import sys
2+
import tempfile
23
from _typeshed import ReadableBuffer
34
from collections.abc import Callable, Iterable
45
from email.message import Message
56
from types import TracebackType
6-
from typing import IO, Any, BinaryIO
7-
from typing_extensions import Self
7+
from typing import IO, Any
88

99
__all__ = ["addbase", "addclosehook", "addinfo", "addinfourl"]
1010

11-
class addbase(BinaryIO):
11+
class addbase(tempfile._TemporaryFileWrapper[bytes]):
1212
fp: IO[bytes]
1313
def __init__(self, fp: IO[bytes]) -> None: ...
14-
def __enter__(self) -> Self: ...
1514
def __exit__(
1615
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
1716
) -> None: ...
18-
def __iter__(self) -> Self: ...
19-
def __next__(self) -> bytes: ...
20-
def close(self) -> None: ...
2117
# These methods don't actually exist, but the class inherits at runtime from
2218
# tempfile._TemporaryFileWrapper, which uses __getattr__ to delegate to the
2319
# underlying file object. To satisfy the BinaryIO interface, we pretend that this
2420
# class has these additional methods.
25-
def fileno(self) -> int: ...
26-
def flush(self) -> None: ...
27-
def isatty(self) -> bool: ...
28-
def read(self, n: int = ...) -> bytes: ...
29-
def readable(self) -> bool: ...
30-
def readline(self, limit: int = ...) -> bytes: ...
31-
def readlines(self, hint: int = ...) -> list[bytes]: ...
32-
def seek(self, offset: int, whence: int = ...) -> int: ...
33-
def seekable(self) -> bool: ...
34-
def tell(self) -> int: ...
35-
def truncate(self, size: int | None = ...) -> int: ...
36-
def writable(self) -> bool: ...
3721
def write(self, s: ReadableBuffer) -> int: ...
3822
def writelines(self, lines: Iterable[ReadableBuffer]) -> None: ...
3923

0 commit comments

Comments
 (0)