diff --git a/stdlib/zipfile.pyi b/stdlib/zipfile.pyi index ec64b02e9..b60ece6ad 100644 --- a/stdlib/zipfile.pyi +++ b/stdlib/zipfile.pyi @@ -1,6 +1,6 @@ import io import sys -from _typeshed import Self, StrPath +from _typeshed import Self, StrOrBytesPath, StrPath from os import PathLike from types import TracebackType from typing import IO, Any, Callable, Iterable, Iterator, Protocol, Sequence, overload @@ -25,6 +25,12 @@ class _ZipStream(Protocol): # def tell(self) -> int: ... # def seek(self, __n: int) -> object: ... +# Stream shape as required by _EndRecData() and _EndRecData64(). +class _SupportsReadSeekTell(Protocol): + def read(self, __n: int = ...) -> bytes: ... + def seek(self, __cookie: int, __whence: int) -> object: ... + def tell(self) -> int: ... + class _ClosableZipStream(_ZipStream, Protocol): def close(self) -> object: ... @@ -262,7 +268,7 @@ if sys.version_info >= (3, 8): def __truediv__(self, add: StrPath) -> Path: ... -def is_zipfile(filename: StrPath | IO[bytes]) -> bool: ... +def is_zipfile(filename: StrOrBytesPath | _SupportsReadSeekTell) -> bool: ... ZIP_STORED: int ZIP_DEFLATED: int