mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
is_zipfile() also accepts bytes paths (#7106)
Use a protocol for is_zipfile(), instead of IO
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user