|
10 | 10 | from bisect import bisect_right
|
11 | 11 | from contextlib import contextmanager
|
12 | 12 | from tempfile import NamedTemporaryFile
|
| 13 | +from typing import IO |
13 | 14 | from typing import TYPE_CHECKING
|
14 | 15 | from typing import Any
|
15 |
| -from typing import BinaryIO |
16 | 16 | from typing import ClassVar
|
17 |
| -from typing import cast |
18 | 17 | from urllib.parse import urlparse
|
19 | 18 | from zipfile import BadZipFile
|
20 | 19 | from zipfile import ZipFile
|
@@ -168,14 +167,14 @@ def minimal_intervals_covering(
|
168 | 167 | yield from self._merge(start, end, left, right)
|
169 | 168 |
|
170 | 169 |
|
171 |
| -class ReadOnlyIOWrapper(BinaryIO): |
172 |
| - """Implement read-side ``BinaryIO`` methods wrapping an inner ``BinaryIO``. |
| 170 | +class ReadOnlyIOWrapper(IO[bytes]): |
| 171 | + """Implement read-side ``IO[bytes]`` methods wrapping an inner ``IO[bytes]``. |
173 | 172 |
|
174 | 173 | This wrapper is useful because Python currently does not distinguish read-only
|
175 | 174 | streams at the type level.
|
176 | 175 | """
|
177 | 176 |
|
178 |
| - def __init__(self, inner: BinaryIO) -> None: |
| 177 | + def __init__(self, inner: IO[bytes]) -> None: |
179 | 178 | self._file = inner
|
180 | 179 |
|
181 | 180 | def __enter__(self) -> Self:
|
@@ -296,7 +295,8 @@ def __init__(
|
296 | 295 | session: Session | Authenticator,
|
297 | 296 | delete_backing_file: bool = True,
|
298 | 297 | ) -> None:
|
299 |
| - super().__init__(cast(BinaryIO, NamedTemporaryFile(delete=delete_backing_file))) |
| 298 | + inner = NamedTemporaryFile(delete=delete_backing_file) # noqa: SIM115 |
| 299 | + super().__init__(inner) |
300 | 300 |
|
301 | 301 | self._merge_intervals: MergeIntervals | None = None
|
302 | 302 | self._length: int | None = None
|
|
0 commit comments