Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/py314.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ multiprocessing.managers._BaseDictProxy.__ror__
multiprocessing.managers._BaseDictProxy.fromkeys
multiprocessing.process.BaseProcess.interrupt
multiprocessing.synchronize.SemLock.locked
tarfile.TarFile.zstopen

# =========================
# New errors in Python 3.14
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
121 changes: 117 additions & 4 deletions stdlib/tarfile.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ from types import TracebackType
from typing import IO, ClassVar, Literal, Protocol, overload
from typing_extensions import Self, TypeAlias, deprecated

if sys.version_info >= (3, 14):
from compression.zstd import ZstdDict

__all__ = [
"TarFile",
"TarInfo",
Expand Down Expand Up @@ -186,6 +189,30 @@ class TarFile:
debug: int | None = ...,
errorlevel: int | None = ...,
) -> Self: ...
if sys.version_info >= (3, 14):
@overload
@classmethod
def open(
cls,
name: StrOrBytesPath | None,
mode: Literal["r:zst"],
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 = ...,
level: None = None,
options: Mapping[int, int] | None = None,
zstd_dict: ZstdDict | None = None,
) -> Self: ...

@overload
@classmethod
def open(
Expand Down Expand Up @@ -304,12 +331,56 @@ class TarFile:
errorlevel: int | None = ...,
preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ...,
) -> Self: ...
if sys.version_info >= (3, 14):
@overload
@classmethod
def open(
cls,
name: StrOrBytesPath | None,
mode: Literal["x:zst", "w:zst"],
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 = ...,
options: Mapping[int, int] | None = None,
zstd_dict: ZstdDict | None = None,
) -> Self: ...
@overload
@classmethod
def open(
cls,
name: StrOrBytesPath | None = None,
*,
mode: Literal["x:zst", "w:zst"],
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 = ...,
options: Mapping[int, int] | None = None,
zstd_dict: ZstdDict | None = None,
) -> Self: ...

@overload
@classmethod
def open(
cls,
name: StrOrBytesPath | ReadableBuffer | None,
mode: Literal["r|*", "r|", "r|gz", "r|bz2", "r|xz"],
mode: Literal["r|*", "r|", "r|gz", "r|bz2", "r|xz", "r|zst"],
fileobj: _Fileobj | None = None,
bufsize: int = 10240,
*,
Expand All @@ -329,7 +400,7 @@ class TarFile:
cls,
name: StrOrBytesPath | ReadableBuffer | None = None,
*,
mode: Literal["r|*", "r|", "r|gz", "r|bz2", "r|xz"],
mode: Literal["r|*", "r|", "r|gz", "r|bz2", "r|xz", "r|zst"],
fileobj: _Fileobj | None = None,
bufsize: int = 10240,
format: int | None = ...,
Expand All @@ -347,7 +418,7 @@ class TarFile:
def open(
cls,
name: StrOrBytesPath | WriteableBuffer | None,
mode: Literal["w|", "w|xz"],
mode: Literal["w|", "w|xz", "w|zst"],
fileobj: _Fileobj | None = None,
bufsize: int = 10240,
*,
Expand All @@ -367,7 +438,7 @@ class TarFile:
cls,
name: StrOrBytesPath | WriteableBuffer | None = None,
*,
mode: Literal["w|", "w|xz"],
mode: Literal["w|", "w|xz", "w|zst"],
fileobj: _Fileobj | None = None,
bufsize: int = 10240,
format: int | None = ...,
Expand Down Expand Up @@ -526,6 +597,48 @@ class TarFile:
debug: int | None = ...,
errorlevel: int | None = ...,
) -> Self: ...
if sys.version_info >= (3, 14):
@overload
@classmethod
def zstopen(
cls,
name: StrOrBytesPath | None,
mode: Literal["r"] = "r",
fileobj: IO[bytes] | None = None,
level: None = None,
options: Mapping[int, int] | None = None,
zstd_dict: ZstdDict | None = None,
*,
format: int | None = ...,
tarinfo: type[TarInfo] | None = ...,
dereference: bool | None = ...,
ignore_zeros: bool | None = ...,
encoding: str | None = ...,
pax_headers: Mapping[str, str] | None = ...,
debug: int | None = ...,
errorlevel: int | None = ...,
) -> Self: ...
@overload
@classmethod
def zstopen(
cls,
name: StrOrBytesPath | None,
mode: Literal["w", "x"],
fileobj: IO[bytes] | None = None,
level: int | None = None,
options: Mapping[int, int] | None = None,
zstd_dict: ZstdDict | None = None,
*,
format: int | None = ...,
tarinfo: type[TarInfo] | None = ...,
dereference: bool | None = ...,
ignore_zeros: bool | None = ...,
encoding: str | None = ...,
pax_headers: Mapping[str, str] | None = ...,
debug: int | None = ...,
errorlevel: int | None = ...,
) -> Self: ...

def getmember(self, name: str) -> TarInfo: ...
def getmembers(self) -> _list[TarInfo]: ...
def getnames(self) -> _list[str]: ...
Expand Down