From 02a9a0e8485a85c55264004764c3aec6129fa6e2 Mon Sep 17 00:00:00 2001 From: Semyon Moroz Date: Mon, 28 Apr 2025 15:41:28 +0400 Subject: [PATCH] Deprecate `TarInfo.tarfile` attribute (#13894) --- stdlib/tarfile.pyi | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index cd31b101c..50546be8e 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -7,7 +7,7 @@ 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_extensions import Self, TypeAlias +from typing_extensions import Self, TypeAlias, deprecated __all__ = [ "TarFile", @@ -622,7 +622,6 @@ class TarInfo: offset: int offset_data: int sparse: bytes | None - tarfile: TarFile | None mode: int type: bytes linkname: str @@ -632,6 +631,16 @@ class TarInfo: gname: str pax_headers: Mapping[str, str] def __init__(self, name: str = "") -> None: ... + if sys.version_info >= (3, 13): + @property + @deprecated("Deprecated in Python 3.13; removal scheduled for Python 3.16") + def tarfile(self) -> TarFile | None: ... + @tarfile.setter + @deprecated("Deprecated in Python 3.13; removal scheduled for Python 3.16") + def tarfile(self) -> None: ... + else: + tarfile: TarFile | None + @classmethod def frombuf(cls, buf: bytes | bytearray, encoding: str, errors: str) -> Self: ... @classmethod