|
1 | 1 | import bz2
|
2 | 2 | import io
|
3 | 3 | import sys
|
4 |
| -from _typeshed import StrOrBytesPath, StrPath, SupportsRead |
| 4 | +from _typeshed import ReadableBuffer, StrOrBytesPath, StrPath, SupportsRead, WriteableBuffer |
5 | 5 | from builtins import list as _list # aliases to avoid name clashes with fields named "type" or "list"
|
6 | 6 | from collections.abc import Callable, Iterable, Iterator, Mapping
|
7 | 7 | from gzip import _ReadableFileobj as _GzipReadableFileobj, _WritableFileobj as _GzipWritableFileobj
|
@@ -226,15 +226,29 @@ def open(
|
226 | 226 | errorlevel: int | None = ...,
|
227 | 227 | preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ...,
|
228 | 228 | ) -> TarFile: ...
|
229 |
| - |
230 |
| -# TODO: Temporary fallback for modes containing pipe characters. These don't |
231 |
| -# work with mypy 1.10, but this should be fixed with mypy 1.11. |
232 |
| -# https://github.com/python/typeshed/issues/12182 |
233 | 229 | @overload
|
234 | 230 | def open(
|
235 |
| - name: StrOrBytesPath | None = None, |
| 231 | + name: StrOrBytesPath | ReadableBuffer | None = None, |
| 232 | + *, |
| 233 | + mode: Literal["r|*", "r|", "r|gz", "r|bz2", "r|xz"], |
| 234 | + fileobj: IO[bytes] | None = None, |
| 235 | + bufsize: int = 10240, |
| 236 | + format: int | None = ..., |
| 237 | + tarinfo: type[TarInfo] | None = ..., |
| 238 | + dereference: bool | None = ..., |
| 239 | + ignore_zeros: bool | None = ..., |
| 240 | + encoding: str | None = ..., |
| 241 | + errors: str = ..., |
| 242 | + pax_headers: Mapping[str, str] | None = ..., |
| 243 | + debug: int | None = ..., |
| 244 | + errorlevel: int | None = ..., |
| 245 | + preset: int | None = ..., |
| 246 | +) -> TarFile: ... |
| 247 | +@overload |
| 248 | +def open( |
| 249 | + name: StrOrBytesPath | WriteableBuffer | None = None, |
236 | 250 | *,
|
237 |
| - mode: str, |
| 251 | + mode: Literal["w|", "w|gz", "w|bz2", "w|xz"], |
238 | 252 | fileobj: IO[bytes] | None = None,
|
239 | 253 | bufsize: int = 10240,
|
240 | 254 | format: int | None = ...,
|
|
0 commit comments