zipfile: update for py38 (#3572)

* zipfile: add Path, new in py38
* zipfile: use str over Text for py3 branches
* zipfile: add force_zip64 kwarg to open methods
This commit is contained in:
hauntsaninja
2020-01-06 11:52:46 -08:00
committed by Sebastian Rittau
parent 2cff4e615e
commit e10b9c70b2

View File

@@ -1,6 +1,6 @@
# Stubs for zipfile
from typing import Callable, Dict, IO, Iterable, List, Optional, Text, Tuple, Type, Union, Sequence, Pattern
from typing import Callable, Dict, IO, Iterable, Iterator, List, Optional, Text, Tuple, Type, Union, Sequence, Pattern
from types import TracebackType
import io
import os
@@ -60,7 +60,7 @@ class ZipFile:
def __init__(
self,
file: Union[_Path, IO[bytes]],
mode: Text = ...,
mode: str = ...,
compression: int = ...,
allowZip64: bool = ...,
compresslevel: Optional[int] = ...,
@@ -71,7 +71,7 @@ class ZipFile:
def __init__(
self,
file: Union[_Path, IO[bytes]],
mode: Text = ...,
mode: str = ...,
compression: int = ...,
allowZip64: bool = ...,
compresslevel: Optional[int] = ...,
@@ -88,7 +88,7 @@ class ZipFile:
def getinfo(self, name: Text) -> ZipInfo: ...
def infolist(self) -> List[ZipInfo]: ...
def namelist(self) -> List[Text]: ...
def open(self, name: _SZI, mode: Text = ..., pwd: Optional[bytes] = ...) -> IO[bytes]: ...
def open(self, name: _SZI, mode: Text = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ...) -> IO[bytes]: ...
def extract(self, member: _SZI, path: Optional[_SZI] = ..., pwd: bytes = ...) -> str: ...
def extractall(
self, path: Optional[_Path] = ..., members: Optional[Iterable[Text]] = ..., pwd: Optional[bytes] = ...
@@ -131,12 +131,40 @@ class ZipInfo:
compress_size: int
file_size: int
def __init__(self, filename: Optional[Text] = ..., date_time: Optional[_DT] = ...) -> None: ...
if sys.version_info >= (3, 6):
def is_dir(self) -> bool: ...
if sys.version_info >= (3, 8):
@classmethod
def from_file(cls, filename: _Path, arcname: Optional[_Path] = ..., *, strict_timestamps: bool = ...) -> ZipInfo: ...
elif sys.version_info >= (3, 6):
@classmethod
def from_file(cls, filename: _Path, arcname: Optional[_Path] = ...) -> ZipInfo: ...
if sys.version_info >= (3, 6):
def is_dir(self) -> bool: ...
def FileHeader(self, zip64: Optional[bool] = ...) -> bytes: ...
if sys.version_info >= (3, 8):
class Path:
@property
def name(self) -> str: ...
@property
def parent(self) -> Path: ... # undocumented
def __init__(self, root: Union[ZipFile, _Path, IO[bytes]], at: str = ...) -> None: ...
def open(self, mode: str = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ...) -> IO[bytes]: ...
def iterdir(self) -> Iterator[Path]: ...
def is_dir(self) -> bool: ...
def is_file(self) -> bool: ...
def exists(self) -> bool: ...
def read_text(
self,
encoding: Optional[str] = ...,
errors: Optional[str] = ...,
newline: Optional[str] = ...,
line_buffering: bool = ...,
write_through: bool = ...,
) -> str: ...
def read_bytes(self) -> bytes: ...
def joinpath(self, add: _Path) -> Path: ... # undocumented
def __truediv__(self, add: _Path) -> Path: ...
def is_zipfile(filename: Union[_Path, IO[bytes]]) -> bool: ...
ZIP_STORED: int