Skip to content

Fix todo in tarfile for modes with pipe char #13130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions stdlib/tarfile.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import bz2
import io
import sys
from _typeshed import StrOrBytesPath, StrPath, SupportsRead
from _typeshed import ReadableBuffer, StrOrBytesPath, StrPath, SupportsRead, WriteableBuffer
from builtins import list as _list # aliases to avoid name clashes with fields named "type" or "list"
from collections.abc import Callable, Iterable, Iterator, Mapping
from gzip import _ReadableFileobj as _GzipReadableFileobj, _WritableFileobj as _GzipWritableFileobj
Expand Down Expand Up @@ -226,15 +226,29 @@ def open(
errorlevel: int | None = ...,
preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ...,
) -> TarFile: ...

# TODO: Temporary fallback for modes containing pipe characters. These don't
# work with mypy 1.10, but this should be fixed with mypy 1.11.
# https://github.com/python/typeshed/issues/12182
@overload
def open(
name: StrOrBytesPath | None = None,
name: StrOrBytesPath | ReadableBuffer | None = None,
*,
mode: Literal["r|*", "r|", "r|gz", "r|bz2", "r|xz"],
fileobj: IO[bytes] | None = None,
bufsize: int = 10240,
format: int | None = ...,
tarinfo: type[TarInfo] | None = ...,
dereference: bool | None = ...,
ignore_zeros: bool | None = ...,
encoding: str | None = ...,
errors: str = ...,
pax_headers: Mapping[str, str] | None = ...,
debug: int | None = ...,
errorlevel: int | None = ...,
preset: int | None = ...,
) -> TarFile: ...
@overload
def open(
name: StrOrBytesPath | WriteableBuffer | None = None,
*,
mode: str,
mode: Literal["w|", "w|gz", "w|bz2", "w|xz"],
fileobj: IO[bytes] | None = None,
bufsize: int = 10240,
format: int | None = ...,
Expand Down