Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b308c1f

Browse files
authored
bz2 stub exceptions (#5199)
1 parent 25bac1d commit b308c1f

6 files changed

Lines changed: 16 additions & 14 deletions

File tree

stdlib/bz2.pyi

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import io
22
import sys
3-
from _typeshed import AnyPath
4-
from typing import IO, Any, Optional, TextIO, TypeVar, Union, overload
5-
from typing_extensions import Literal
3+
from _typeshed import AnyPath, ReadableBuffer, WriteableBuffer
4+
from typing import IO, Any, Iterable, List, Optional, TextIO, TypeVar, Union, overload
5+
from typing_extensions import Literal, SupportsIndex
66

77
_PathOrFile = Union[AnyPath, IO[bytes]]
88
_T = TypeVar("_T")
@@ -49,10 +49,18 @@ class BZ2File(io.BufferedIOBase, IO[bytes]):
4949
def __init__(
5050
self, filename: _PathOrFile, mode: str = ..., buffering: Optional[Any] = ..., compresslevel: int = ...
5151
) -> None: ...
52+
def read(self, size: Optional[int] = ...) -> bytes: ...
53+
def read1(self, size: int = ...) -> bytes: ...
54+
def readline(self, size: SupportsIndex = ...) -> bytes: ... # type: ignore
55+
def readinto(self, b: WriteableBuffer) -> int: ...
56+
def readlines(self, size: SupportsIndex = ...) -> List[bytes]: ...
57+
def seek(self, offset: int, whence: int = ...) -> int: ...
58+
def write(self, data: ReadableBuffer) -> int: ...
59+
def writelines(self, seq: Iterable[ReadableBuffer]) -> None: ...
5260

5361
class BZ2Compressor(object):
5462
def __init__(self, compresslevel: int = ...) -> None: ...
55-
def compress(self, data: bytes) -> bytes: ...
63+
def compress(self, __data: bytes) -> bytes: ...
5664
def flush(self) -> bytes: ...
5765

5866
class BZ2Decompressor(object):

tests/stubtest_whitelists/py36.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ asyncio.staggered # Added in Python 3.8
1212
asyncio.threads # Added in Python 3.9
1313
asyncio.trsock # Added in Python 3.8
1414
builtins.str.maketrans
15+
bz2.BZ2Compressor.compress # does not accept keyword arguments even though signature says it does
1516
cmath.log
1617
collections.AsyncGenerator.ag_await
1718
collections.AsyncGenerator.ag_code

tests/stubtest_whitelists/py37.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ asyncio.threads # Added in Python 3.9
1313
asyncio.trsock # Added in Python 3.8
1414
builtins.dict.get
1515
builtins.str.maketrans
16+
bz2.BZ2Compressor.compress # does not accept keyword arguments even though signature says it does
1617
cmath.log
1718
collections.AsyncGenerator.ag_await
1819
collections.AsyncGenerator.ag_code

tests/stubtest_whitelists/py38.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ asyncio.run # Bugfix involving this was backported to 3.8
2323
asyncio.runners.run # It just hasn't been released yet
2424
asyncio.threads # Added in Python 3.9
2525
builtins.dict.get
26+
bz2.BZ2Compressor.compress # does not accept keyword arguments even though signature says it does
2627
collections.AsyncGenerator.ag_await
2728
collections.AsyncGenerator.ag_code
2829
collections.AsyncGenerator.ag_frame

tests/stubtest_whitelists/py39.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,6 @@ xml.etree.cElementTree.XMLParser.__init__ # Defined in C so has general signatu
135135
# positional-only complaints
136136
builtins.bytearray.pop
137137
builtins.bytearray.remove
138-
bz2.BZ2Compressor.compress
139-
bz2.BZ2File.read
140-
bz2.BZ2File.read1
141-
bz2.BZ2File.readline
142-
bz2.BZ2File.seek
143138
collections.AsyncGenerator.asend
144139
collections.AsyncGenerator.athrow
145140
collections.Container.__contains__

tests/stubtest_whitelists/py3_common.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,7 @@ builtins.property.fset
7373
builtins.reversed # not a function at runtime
7474
builtins.staticmethod.__get__
7575
builtins.zip # not a function at runtime
76-
bz2.BZ2Decompressor.__init__
77-
bz2.BZ2File.readinto
78-
bz2.BZ2File.readlines
79-
bz2.BZ2File.write
80-
bz2.BZ2File.writelines
76+
bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
8177
# The following methods were changed in point releases from Python 3.6 to 3.9
8278
# as part of a security fix. These excludes can be removed when the GitHub
8379
# action workflow uses Python versions that include the fix (adding a

0 commit comments

Comments
 (0)