zipfile: fix various stubs (#3621)

Found using new stub checking script
This commit is contained in:
Shantanu
2020-01-19 04:52:08 -06:00
committed by Sebastian Rittau
parent 5d328a0c3f
commit 995e83ba2a

View File

@@ -1,6 +1,6 @@
# Stubs for zipfile
from typing import Callable, Dict, IO, Iterable, Iterator, List, Optional, Text, Tuple, Type, Union, Sequence, Pattern
from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, Protocol, Text, Tuple, Type, Union, Sequence, Pattern
from types import TracebackType
import io
import os
@@ -58,6 +58,9 @@ class ZipExtFile(io.BufferedIOBase):
def peek(self, n: int = ...) -> bytes: ...
def read1(self, n: Optional[int]) -> bytes: ... # type: ignore
class _Writer(Protocol):
def write(self, __s: str) -> Any: ...
class ZipFile:
filename: Optional[Text]
debug: int
@@ -103,12 +106,20 @@ class ZipFile:
def extractall(
self, path: Optional[_Path] = ..., members: Optional[Iterable[Text]] = ..., pwd: Optional[bytes] = ...
) -> None: ...
def printdir(self) -> None: ...
if sys.version_info >= (3,):
def printdir(self, file: Optional[_Writer] = ...) -> None: ...
else:
def printdir(self) -> None: ...
def setpassword(self, pwd: bytes) -> None: ...
def read(self, name: _SZI, pwd: Optional[bytes] = ...) -> bytes: ...
def testzip(self) -> Optional[str]: ...
def write(self, filename: _Path, arcname: Optional[_Path] = ..., compress_type: Optional[int] = ...) -> None: ...
if sys.version_info >= (3,):
if sys.version_info >= (3, 7):
def write(self, filename: _Path, arcname: Optional[_Path] = ..., compress_type: Optional[int] = ..., compresslevel: Optional[int] = ...) -> None: ...
else:
def write(self, filename: _Path, arcname: Optional[_Path] = ..., compress_type: Optional[int] = ...) -> None: ...
if sys.version_info >= (3, 7):
def writestr(self, zinfo_or_arcname: _SZI, data: Union[bytes, str], compress_type: Optional[int] = ..., compresslevel: Optional[int] = ...) -> None: ...
elif sys.version_info >= (3,):
def writestr(self, zinfo_or_arcname: _SZI, data: Union[bytes, str], compress_type: Optional[int] = ...) -> None: ...
else:
def writestr(self, zinfo_or_arcname: _SZI, bytes: bytes, compress_type: Optional[int] = ...) -> None: ...