Skip to content

Commit ba85e0c

Browse files
authored
Fix tarfile.open overloads (#13441)
* Allow `compresslevel` argument for modes `w|gz` and `w|bz2`. * Remove `preset` argument from modes where it's not allowed. Closes: #13440
1 parent 91a90ed commit ba85e0c

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

stdlib/tarfile.pyi

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,12 @@ def open(
242242
pax_headers: Mapping[str, str] | None = ...,
243243
debug: int | None = ...,
244244
errorlevel: int | None = ...,
245-
preset: int | None = ...,
246245
) -> TarFile: ...
247246
@overload
248247
def open(
249248
name: StrOrBytesPath | WriteableBuffer | None = None,
250249
*,
251-
mode: Literal["w|", "w|gz", "w|bz2", "w|xz"],
250+
mode: Literal["w|", "w|xz"],
252251
fileobj: IO[bytes] | None = None,
253252
bufsize: int = 10240,
254253
format: int | None = ...,
@@ -260,7 +259,24 @@ def open(
260259
pax_headers: Mapping[str, str] | None = ...,
261260
debug: int | None = ...,
262261
errorlevel: int | None = ...,
263-
preset: int | None = ...,
262+
) -> TarFile: ...
263+
@overload
264+
def open(
265+
name: StrOrBytesPath | WriteableBuffer | None = None,
266+
*,
267+
mode: Literal["w|gz", "w|bz2"],
268+
fileobj: IO[bytes] | None = None,
269+
bufsize: int = 10240,
270+
format: int | None = ...,
271+
tarinfo: type[TarInfo] | None = ...,
272+
dereference: bool | None = ...,
273+
ignore_zeros: bool | None = ...,
274+
encoding: str | None = ...,
275+
errors: str = ...,
276+
pax_headers: Mapping[str, str] | None = ...,
277+
debug: int | None = ...,
278+
errorlevel: int | None = ...,
279+
compresslevel: int = 9,
264280
) -> TarFile: ...
265281

266282
class ExFileObject(io.BufferedReader):

0 commit comments

Comments
 (0)