Skip to content

Commit 1ae7e61

Browse files
authored
Loosen type of fileobj argument to TarFile.addfile (#12961)
It only seems to need something it can read bytes from, rather than a full-fledged `IO[bytes]`.
1 parent 8dd4371 commit 1ae7e61

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

stdlib/tarfile.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import bz2
22
import io
33
import sys
4-
from _typeshed import StrOrBytesPath, StrPath
4+
from _typeshed import StrOrBytesPath, StrPath, SupportsRead
55
from builtins import list as _list # aliases to avoid name clashes with fields named "type" or "list"
66
from collections.abc import Callable, Iterable, Iterator, Mapping
77
from gzip import _ReadableFileobj as _GzipReadableFileobj, _WritableFileobj as _GzipWritableFileobj
@@ -481,7 +481,7 @@ class TarFile:
481481
*,
482482
filter: Callable[[TarInfo], TarInfo | None] | None = None,
483483
) -> None: ...
484-
def addfile(self, tarinfo: TarInfo, fileobj: IO[bytes] | None = None) -> None: ...
484+
def addfile(self, tarinfo: TarInfo, fileobj: SupportsRead[bytes] | None = None) -> None: ...
485485
def gettarinfo(
486486
self, name: StrOrBytesPath | None = None, arcname: str | None = None, fileobj: IO[bytes] | None = None
487487
) -> TarInfo: ...

0 commit comments

Comments
 (0)