From b308c1f964e4bb854ea0144e6c170b3b66918b5b Mon Sep 17 00:00:00 2001 From: hatal175 Date: Sun, 11 Apr 2021 05:53:05 +0300 Subject: [PATCH] bz2 stub exceptions (#5199) --- stdlib/bz2.pyi | 16 ++++++++++++---- tests/stubtest_whitelists/py36.txt | 1 + tests/stubtest_whitelists/py37.txt | 1 + tests/stubtest_whitelists/py38.txt | 1 + tests/stubtest_whitelists/py39.txt | 5 ----- tests/stubtest_whitelists/py3_common.txt | 6 +----- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/stdlib/bz2.pyi b/stdlib/bz2.pyi index b67d00cc7..dfc1876bf 100644 --- a/stdlib/bz2.pyi +++ b/stdlib/bz2.pyi @@ -1,8 +1,8 @@ import io import sys -from _typeshed import AnyPath -from typing import IO, Any, Optional, TextIO, TypeVar, Union, overload -from typing_extensions import Literal +from _typeshed import AnyPath, ReadableBuffer, WriteableBuffer +from typing import IO, Any, Iterable, List, Optional, TextIO, TypeVar, Union, overload +from typing_extensions import Literal, SupportsIndex _PathOrFile = Union[AnyPath, IO[bytes]] _T = TypeVar("_T") @@ -49,10 +49,18 @@ class BZ2File(io.BufferedIOBase, IO[bytes]): def __init__( self, filename: _PathOrFile, mode: str = ..., buffering: Optional[Any] = ..., compresslevel: int = ... ) -> None: ... + def read(self, size: Optional[int] = ...) -> bytes: ... + def read1(self, size: int = ...) -> bytes: ... + def readline(self, size: SupportsIndex = ...) -> bytes: ... # type: ignore + def readinto(self, b: WriteableBuffer) -> int: ... + def readlines(self, size: SupportsIndex = ...) -> List[bytes]: ... + def seek(self, offset: int, whence: int = ...) -> int: ... + def write(self, data: ReadableBuffer) -> int: ... + def writelines(self, seq: Iterable[ReadableBuffer]) -> None: ... class BZ2Compressor(object): def __init__(self, compresslevel: int = ...) -> None: ... - def compress(self, data: bytes) -> bytes: ... + def compress(self, __data: bytes) -> bytes: ... def flush(self) -> bytes: ... class BZ2Decompressor(object): diff --git a/tests/stubtest_whitelists/py36.txt b/tests/stubtest_whitelists/py36.txt index d30722aef..d1a1dc1b4 100644 --- a/tests/stubtest_whitelists/py36.txt +++ b/tests/stubtest_whitelists/py36.txt @@ -12,6 +12,7 @@ asyncio.staggered # Added in Python 3.8 asyncio.threads # Added in Python 3.9 asyncio.trsock # Added in Python 3.8 builtins.str.maketrans +bz2.BZ2Compressor.compress # does not accept keyword arguments even though signature says it does cmath.log collections.AsyncGenerator.ag_await collections.AsyncGenerator.ag_code diff --git a/tests/stubtest_whitelists/py37.txt b/tests/stubtest_whitelists/py37.txt index 44287e09c..921439df8 100644 --- a/tests/stubtest_whitelists/py37.txt +++ b/tests/stubtest_whitelists/py37.txt @@ -13,6 +13,7 @@ asyncio.threads # Added in Python 3.9 asyncio.trsock # Added in Python 3.8 builtins.dict.get builtins.str.maketrans +bz2.BZ2Compressor.compress # does not accept keyword arguments even though signature says it does cmath.log collections.AsyncGenerator.ag_await collections.AsyncGenerator.ag_code diff --git a/tests/stubtest_whitelists/py38.txt b/tests/stubtest_whitelists/py38.txt index 73cc05ba6..ad73f1e7f 100644 --- a/tests/stubtest_whitelists/py38.txt +++ b/tests/stubtest_whitelists/py38.txt @@ -23,6 +23,7 @@ asyncio.run # Bugfix involving this was backported to 3.8 asyncio.runners.run # It just hasn't been released yet asyncio.threads # Added in Python 3.9 builtins.dict.get +bz2.BZ2Compressor.compress # does not accept keyword arguments even though signature says it does collections.AsyncGenerator.ag_await collections.AsyncGenerator.ag_code collections.AsyncGenerator.ag_frame diff --git a/tests/stubtest_whitelists/py39.txt b/tests/stubtest_whitelists/py39.txt index 858e3f071..6bf0f7247 100644 --- a/tests/stubtest_whitelists/py39.txt +++ b/tests/stubtest_whitelists/py39.txt @@ -135,11 +135,6 @@ xml.etree.cElementTree.XMLParser.__init__ # Defined in C so has general signatu # positional-only complaints builtins.bytearray.pop builtins.bytearray.remove -bz2.BZ2Compressor.compress -bz2.BZ2File.read -bz2.BZ2File.read1 -bz2.BZ2File.readline -bz2.BZ2File.seek collections.AsyncGenerator.asend collections.AsyncGenerator.athrow collections.Container.__contains__ diff --git a/tests/stubtest_whitelists/py3_common.txt b/tests/stubtest_whitelists/py3_common.txt index bdfe18946..5e20dc057 100644 --- a/tests/stubtest_whitelists/py3_common.txt +++ b/tests/stubtest_whitelists/py3_common.txt @@ -73,11 +73,7 @@ builtins.property.fset builtins.reversed # not a function at runtime builtins.staticmethod.__get__ builtins.zip # not a function at runtime -bz2.BZ2Decompressor.__init__ -bz2.BZ2File.readinto -bz2.BZ2File.readlines -bz2.BZ2File.write -bz2.BZ2File.writelines +bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set # The following methods were changed in point releases from Python 3.6 to 3.9 # as part of a security fix. These excludes can be removed when the GitHub # action workflow uses Python versions that include the fix (adding a