Skip to content

Fix incorrect keyword-only arguments in tarfile.open() #13814

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 2 commits into from
Apr 11, 2025
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
4 changes: 4 additions & 0 deletions stdlib/@tests/test_cases/check_tarfile.py
Original file line number Diff line number Diff line change
@@ -11,3 +11,7 @@
# Test with invalid preset values
tarfile.open("test.tar.xz", "w:xz", preset=-1) # type: ignore
tarfile.open("test.tar.xz", "w:xz", preset=10) # type: ignore

# Test pipe modes
tarfile.open("test.tar.xz", "r|*")
tarfile.open("test.tar.xz", mode="r|*")
58 changes: 58 additions & 0 deletions stdlib/tarfile.pyi
Original file line number Diff line number Diff line change
@@ -304,6 +304,25 @@ class TarFile:
) -> Self: ...
@overload
@classmethod
def open(
cls,
name: StrOrBytesPath | ReadableBuffer | None,
mode: Literal["r|*", "r|", "r|gz", "r|bz2", "r|xz"],
fileobj: _Fileobj | 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 = ...,
) -> Self: ...
@overload
@classmethod
def open(
cls,
name: StrOrBytesPath | ReadableBuffer | None = None,
@@ -323,6 +342,25 @@ class TarFile:
) -> Self: ...
@overload
@classmethod
def open(
cls,
name: StrOrBytesPath | WriteableBuffer | None,
mode: Literal["w|", "w|xz"],
fileobj: _Fileobj | 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 = ...,
) -> Self: ...
@overload
@classmethod
def open(
cls,
name: StrOrBytesPath | WriteableBuffer | None = None,
@@ -342,6 +380,26 @@ class TarFile:
) -> Self: ...
@overload
@classmethod
def open(
cls,
name: StrOrBytesPath | WriteableBuffer | None,
mode: Literal["w|gz", "w|bz2"],
fileobj: _Fileobj | 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 = ...,
compresslevel: int = 9,
) -> Self: ...
@overload
@classmethod
def open(
cls,
name: StrOrBytesPath | WriteableBuffer | None = None,