2 from _typeshed import Self
3 from email.message import Message
4 from types import TracebackType
5 from typing import IO, Any, BinaryIO, Callable, Iterable, Tuple, Type, TypeVar
7 _AIUT = TypeVar("_AIUT", bound=addbase)
9 class addbase(BinaryIO):
11 def __init__(self, fp: IO[bytes]) -> None: ...
12 def __enter__(self: Self) -> Self: ...
14 self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
16 def __iter__(self: _AIUT) -> _AIUT: ...
17 def __next__(self) -> bytes: ...
18 def close(self) -> None: ...
19 # These methods don't actually exist, but the class inherits at runtime from
20 # tempfile._TemporaryFileWrapper, which uses __getattr__ to delegate to the
21 # underlying file object. To satisfy the BinaryIO interface, we pretend that this
22 # class has these additional methods.
23 def fileno(self) -> int: ...
24 def flush(self) -> None: ...
25 def isatty(self) -> bool: ...
26 def read(self, n: int = ...) -> bytes: ...
27 def readable(self) -> bool: ...
28 def readline(self, limit: int = ...) -> bytes: ...
29 def readlines(self, hint: int = ...) -> list[bytes]: ...
30 def seek(self, offset: int, whence: int = ...) -> int: ...
31 def seekable(self) -> bool: ...
32 def tell(self) -> int: ...
33 def truncate(self, size: int | None = ...) -> int: ...
34 def writable(self) -> bool: ...
35 def write(self, s: bytes) -> int: ...
36 def writelines(self, lines: Iterable[bytes]) -> None: ...
38 class addclosehook(addbase):
39 closehook: Callable[..., object]
40 hookargs: Tuple[Any, ...]
41 def __init__(self, fp: IO[bytes], closehook: Callable[..., object], *hookargs: Any) -> None: ...
43 class addinfo(addbase):
45 def __init__(self, fp: IO[bytes], headers: Message) -> None: ...
46 def info(self) -> Message: ...
48 class addinfourl(addinfo):
51 if sys.version_info >= (3, 9):
53 def status(self) -> int | None: ...
54 def __init__(self, fp: IO[bytes], headers: Message, url: str, code: int | None = ...) -> None: ...
55 def geturl(self) -> str: ...
56 def getcode(self) -> int | None: ...