Skip to content

Commit bb1cbfa

Browse files
Fix incorrect keyword-only arguments in tarfile.open() (#13814)
1 parent 39cfcde commit bb1cbfa

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

stdlib/@tests/test_cases/check_tarfile.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@
1111
# Test with invalid preset values
1212
tarfile.open("test.tar.xz", "w:xz", preset=-1) # type: ignore
1313
tarfile.open("test.tar.xz", "w:xz", preset=10) # type: ignore
14+
15+
# Test pipe modes
16+
tarfile.open("test.tar.xz", "r|*")
17+
tarfile.open("test.tar.xz", mode="r|*")

stdlib/tarfile.pyi

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,25 @@ class TarFile:
304304
) -> Self: ...
305305
@overload
306306
@classmethod
307+
def open(
308+
cls,
309+
name: StrOrBytesPath | ReadableBuffer | None,
310+
mode: Literal["r|*", "r|", "r|gz", "r|bz2", "r|xz"],
311+
fileobj: _Fileobj | None = None,
312+
bufsize: int = 10240,
313+
*,
314+
format: int | None = ...,
315+
tarinfo: type[TarInfo] | None = ...,
316+
dereference: bool | None = ...,
317+
ignore_zeros: bool | None = ...,
318+
encoding: str | None = ...,
319+
errors: str = ...,
320+
pax_headers: Mapping[str, str] | None = ...,
321+
debug: int | None = ...,
322+
errorlevel: int | None = ...,
323+
) -> Self: ...
324+
@overload
325+
@classmethod
307326
def open(
308327
cls,
309328
name: StrOrBytesPath | ReadableBuffer | None = None,
@@ -323,6 +342,25 @@ class TarFile:
323342
) -> Self: ...
324343
@overload
325344
@classmethod
345+
def open(
346+
cls,
347+
name: StrOrBytesPath | WriteableBuffer | None,
348+
mode: Literal["w|", "w|xz"],
349+
fileobj: _Fileobj | None = None,
350+
bufsize: int = 10240,
351+
*,
352+
format: int | None = ...,
353+
tarinfo: type[TarInfo] | None = ...,
354+
dereference: bool | None = ...,
355+
ignore_zeros: bool | None = ...,
356+
encoding: str | None = ...,
357+
errors: str = ...,
358+
pax_headers: Mapping[str, str] | None = ...,
359+
debug: int | None = ...,
360+
errorlevel: int | None = ...,
361+
) -> Self: ...
362+
@overload
363+
@classmethod
326364
def open(
327365
cls,
328366
name: StrOrBytesPath | WriteableBuffer | None = None,
@@ -342,6 +380,26 @@ class TarFile:
342380
) -> Self: ...
343381
@overload
344382
@classmethod
383+
def open(
384+
cls,
385+
name: StrOrBytesPath | WriteableBuffer | None,
386+
mode: Literal["w|gz", "w|bz2"],
387+
fileobj: _Fileobj | None = None,
388+
bufsize: int = 10240,
389+
*,
390+
format: int | None = ...,
391+
tarinfo: type[TarInfo] | None = ...,
392+
dereference: bool | None = ...,
393+
ignore_zeros: bool | None = ...,
394+
encoding: str | None = ...,
395+
errors: str = ...,
396+
pax_headers: Mapping[str, str] | None = ...,
397+
debug: int | None = ...,
398+
errorlevel: int | None = ...,
399+
compresslevel: int = 9,
400+
) -> Self: ...
401+
@overload
402+
@classmethod
345403
def open(
346404
cls,
347405
name: StrOrBytesPath | WriteableBuffer | None = None,

0 commit comments

Comments
 (0)