Skip to content

Commit fcf30cf

Browse files
authored
Fix todo in tarfile for modes with pipe char (#13130)
1 parent 5461d37 commit fcf30cf

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

stdlib/tarfile.pyi

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import bz2
22
import io
33
import sys
4-
from _typeshed import StrOrBytesPath, StrPath, SupportsRead
4+
from _typeshed import ReadableBuffer, StrOrBytesPath, StrPath, SupportsRead, WriteableBuffer
55
from builtins import list as _list # aliases to avoid name clashes with fields named "type" or "list"
66
from collections.abc import Callable, Iterable, Iterator, Mapping
77
from gzip import _ReadableFileobj as _GzipReadableFileobj, _WritableFileobj as _GzipWritableFileobj
@@ -226,15 +226,29 @@ def open(
226226
errorlevel: int | None = ...,
227227
preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ...,
228228
) -> 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
233229
@overload
234230
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,
236250
*,
237-
mode: str,
251+
mode: Literal["w|", "w|gz", "w|bz2", "w|xz"],
238252
fileobj: IO[bytes] | None = None,
239253
bufsize: int = 10240,
240254
format: int | None = ...,

0 commit comments

Comments
 (0)