diff --git a/stdlib/@tests/stubtest_allowlists/py314.txt b/stdlib/@tests/stubtest_allowlists/py314.txt index 53dd45eac25e..62d032eb6965 100644 --- a/stdlib/@tests/stubtest_allowlists/py314.txt +++ b/stdlib/@tests/stubtest_allowlists/py314.txt @@ -22,7 +22,6 @@ multiprocessing.managers._BaseDictProxy.__ror__ multiprocessing.managers._BaseDictProxy.fromkeys multiprocessing.process.BaseProcess.interrupt multiprocessing.synchronize.SemLock.locked -tarfile.TarFile.zstopen tkinter.Event.__class_getitem__ # ========================= diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index a18ef0b823f9..3163ad6e4b4b 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -6,7 +6,7 @@ from builtins import list as _list # aliases to avoid name clashes with fields from collections.abc import Callable, Iterable, Iterator, Mapping from gzip import _ReadableFileobj as _GzipReadableFileobj, _WritableFileobj as _GzipWritableFileobj from types import TracebackType -from typing import IO, ClassVar, Literal, Protocol, overload +from typing import IO, ClassVar, Literal, Protocol, TypedDict, overload from typing_extensions import Self, TypeAlias, deprecated __all__ = [ @@ -105,6 +105,17 @@ PAX_NAME_FIELDS: set[str] ENCODING: str +class _TarOpenOptions(TypedDict, total=False): + compresslevel: int + 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 + class ExFileObject(io.BufferedReader): def __init__(self, tarfile: TarFile, tarinfo: TarInfo) -> None: ... @@ -426,16 +437,7 @@ class TarFile: name: StrOrBytesPath | None, mode: Literal["r", "a", "w", "x"] = "r", fileobj: _Fileobj | None = None, - *, - compresslevel: int = ..., - 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 = ..., + **kwargs: _TarOpenOptions, ) -> Self: ... @overload @classmethod @@ -587,6 +589,33 @@ class TarFile: self, name: StrOrBytesPath | None = None, arcname: str | None = None, fileobj: IO[bytes] | None = None ) -> TarInfo: ... def close(self) -> None: ... + if sys.version_info >= (3, 14): + from compression.zstd import ZstdDict as _ZstdDict + + @classmethod + @overload + def zstopen( + cls, + name: StrOrBytesPath | None, + mode: Literal["r", "rb"] = "r", + fileobj: _Fileobj | None = None, + level: None = None, + options: Mapping[int, int] | None = None, + zstd_dict: _ZstdDict | None = None, + **kwargs: _TarOpenOptions, + ) -> Self: ... + @classmethod + @overload + def zstopen( + cls, + name: StrOrBytesPath | None, + mode: Literal["w", "x"], + fileobj: _Fileobj | None = None, + level: int | None = None, + options: Mapping[int, int] | None = None, + zstd_dict: _ZstdDict | None = None, + **kwargs: _TarOpenOptions, + ) -> Self: ... open = TarFile.open