Python 3.14: PEP-784 zstd in other modules (#14225)

This commit is contained in:
Rogdham
2025-07-07 13:05:45 +02:00
committed by GitHub
parent f64707592d
commit 5d881e4be0
6 changed files with 117 additions and 5 deletions
@@ -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
+117 -4
View File
@@ -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",
@@ -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(
@@ -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,
*,
@@ -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 = ...,
@@ -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,
*,
@@ -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 = ...,
@@ -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]: ...