Akuli and srittau: Remove Python 2 branches from Python 3 stubs (#5461)

* run script and do some manual changes (Akuli)

* do the whole thing manually (srittau)

* merge changes (Akuli)

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
This commit is contained in:
Akuli
2021-05-15 15:33:39 +03:00
committed by GitHub
parent b0ef85288d
commit 17dcea4a68
106 changed files with 1539 additions and 3275 deletions

View File

@@ -2,33 +2,14 @@ import io
import sys
from _typeshed import StrPath
from types import TracebackType
from typing import (
IO,
Any,
Callable,
Dict,
Iterable,
Iterator,
List,
Optional,
Pattern,
Protocol,
Sequence,
Text,
Tuple,
Type,
Union,
)
from typing import IO, Any, Callable, Dict, Iterable, Iterator, List, Optional, Protocol, Sequence, Text, Tuple, Type, Union
_SZI = Union[Text, ZipInfo]
_DT = Tuple[int, int, int, int, int, int]
if sys.version_info >= (3,):
class BadZipFile(Exception): ...
BadZipfile = BadZipFile
else:
class BadZipfile(Exception): ...
class BadZipFile(Exception): ...
BadZipfile = BadZipFile
error = BadZipfile
class LargeZipFile(Exception): ...
@@ -37,9 +18,6 @@ class ZipExtFile(io.BufferedIOBase):
MAX_N: int = ...
MIN_READ_SIZE: int = ...
if sys.version_info < (3, 6):
PATTERN: Pattern[str] = ...
if sys.version_info >= (3, 7):
MAX_SEEK_READ: int = ...
@@ -113,10 +91,7 @@ class ZipFile:
def extractall(
self, path: Optional[StrPath] = ..., members: Optional[Iterable[Text]] = ..., pwd: Optional[bytes] = ...
) -> None: ...
if sys.version_info >= (3,):
def printdir(self, file: Optional[_Writer] = ...) -> None: ...
else:
def printdir(self) -> None: ...
def printdir(self, file: Optional[_Writer] = ...) -> None: ...
def setpassword(self, pwd: bytes) -> None: ...
def read(self, name: _SZI, pwd: Optional[bytes] = ...) -> bytes: ...
def testzip(self) -> Optional[str]: ...
@@ -138,24 +113,14 @@ class ZipFile:
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: ...
def writestr(self, zinfo_or_arcname: _SZI, data: Union[bytes, str], compress_type: Optional[int] = ...) -> None: ...
class PyZipFile(ZipFile):
if sys.version_info >= (3,):
def __init__(
self,
file: Union[str, IO[bytes]],
mode: str = ...,
compression: int = ...,
allowZip64: bool = ...,
optimize: int = ...,
) -> None: ...
def writepy(self, pathname: str, basename: str = ..., filterfunc: Optional[Callable[[str], bool]] = ...) -> None: ...
else:
def writepy(self, pathname: Text, basename: Text = ...) -> None: ...
def __init__(
self, file: Union[str, IO[bytes]], mode: str = ..., compression: int = ..., allowZip64: bool = ..., optimize: int = ...
) -> None: ...
def writepy(self, pathname: str, basename: str = ..., filterfunc: Optional[Callable[[str], bool]] = ...) -> None: ...
class ZipInfo:
filename: Text
@@ -179,11 +144,10 @@ class ZipInfo:
if sys.version_info >= (3, 8):
@classmethod
def from_file(cls, filename: StrPath, arcname: Optional[StrPath] = ..., *, strict_timestamps: bool = ...) -> ZipInfo: ...
elif sys.version_info >= (3, 6):
else:
@classmethod
def from_file(cls, filename: StrPath, arcname: Optional[StrPath] = ...) -> ZipInfo: ...
if sys.version_info >= (3, 6):
def is_dir(self) -> bool: ...
def is_dir(self) -> bool: ...
def FileHeader(self, zip64: Optional[bool] = ...) -> bytes: ...
class _PathOpenProtocol(Protocol):
@@ -224,6 +188,5 @@ ZIP_DEFLATED: int
ZIP64_LIMIT: int
ZIP_FILECOUNT_LIMIT: int
ZIP_MAX_COMMENT: int
if sys.version_info >= (3, 3):
ZIP_BZIP2: int
ZIP_LZMA: int
ZIP_BZIP2: int
ZIP_LZMA: int