Make BytesIO inherit from BufferedIOBase. (#4082)

Co-authored-by: Shantanu <hauntsaninja@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
Tarcisio
2020-05-28 17:07:00 -07:00
committed by GitHub
parent b2b397c5ce
commit b58b8f3b43
6 changed files with 15 additions and 40 deletions

View File

@@ -82,7 +82,7 @@ class GzipFile(_compression.BaseStream):
def writable(self) -> bool: ...
def seekable(self) -> bool: ...
def seek(self, offset: int, whence: int = ...) -> int: ...
def readline(self, size: int = ...) -> bytes: ...
def readline(self, size: Optional[int] = ...) -> bytes: ...
class _GzipReader(_compression.DecompressReader):
def __init__(self, fp: IO[bytes]) -> None: ...

View File

@@ -64,7 +64,7 @@ class IOBase:
def truncate(self, __size: Optional[int] = ...) -> int: ...
def writable(self) -> bool: ...
def writelines(self, __lines: Iterable[Union[bytes, bytearray]]) -> None: ...
def readline(self, __size: int = ...) -> bytes: ...
def readline(self, __size: Optional[int] = ...) -> bytes: ...
def __del__(self) -> None: ...
@property
def closed(self) -> bool: ...
@@ -85,7 +85,6 @@ class BufferedIOBase(IOBase):
def read(self, __size: Optional[int] = ...) -> bytes: ...
def read1(self, __size: int = ...) -> bytes: ...
class FileIO(RawIOBase):
mode: str
name: Union[int, str]
@@ -97,52 +96,27 @@ class FileIO(RawIOBase):
opener: Optional[Callable[[Union[int, str], str], int]] = ...
) -> None: ...
# TODO should extend from BufferedIOBase
class BytesIO(BinaryIO):
class BytesIO(BufferedIOBase, BinaryIO):
def __init__(self, initial_bytes: bytes = ...) -> None: ...
# BytesIO does not contain a "name" field. This workaround is necessary
# to allow BytesIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
name: Any
def __enter__(self: _T) -> _T: ...
def getvalue(self) -> bytes: ...
def getbuffer(self) -> memoryview: ...
# copied from IOBase
def __iter__(self) -> Iterator[bytes]: ...
def __next__(self) -> bytes: ...
def __enter__(self) -> BytesIO: ...
def __exit__(self, t: Optional[Type[BaseException]] = ..., value: Optional[BaseException] = ...,
traceback: Optional[TracebackType] = ...) -> Optional[bool]: ...
def close(self) -> None: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def readable(self) -> bool: ...
def readlines(self, __size: int = ...) -> List[bytes]: ...
def seek(self, __pos: int, __whence: int = ...) -> int: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def truncate(self, __size: Optional[int] = ...) -> int: ...
def writable(self) -> bool: ...
# TODO should be the next line instead
# def writelines(self, lines: List[Union[bytes, bytearray]]) -> None: ...
def writelines(self, __lines: Any) -> None: ...
def readline(self, __size: Optional[int] = ...) -> bytes: ...
def __del__(self) -> None: ...
closed: bool
# copied from BufferedIOBase
def detach(self) -> RawIOBase: ...
def readinto(self, __buffer: _bytearray_like) -> int: ...
def write(self, __b: Union[bytes, bytearray]) -> int: ...
def readinto1(self, __buffer: _bytearray_like) -> int: ...
def read(self, __size: Optional[int] = ...) -> bytes: ...
if sys.version_info >= (3, 7):
def read1(self, __size: Optional[int] = ...) -> bytes: ...
else:
def read1(self, __size: Optional[int]) -> bytes: ...
def read1(self, __size: Optional[int]) -> bytes: ... # type: ignore
class BufferedReader(BufferedIOBase):
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
def peek(self, __size: int = ...) -> bytes: ...
if sys.version_info >= (3, 7):
def read1(self, __size: int = ...) -> bytes: ...
else:
def read1(self, __size: int) -> bytes: ... # type: ignore
class BufferedWriter(BufferedIOBase):
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
@@ -153,6 +127,10 @@ class BufferedRandom(BufferedReader, BufferedWriter):
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
def seek(self, __target: int, __whence: int = ...) -> int: ...
def tell(self) -> int: ...
if sys.version_info >= (3, 7):
def read1(self, __size: int = ...) -> bytes: ...
else:
def read1(self, __size: int) -> bytes: ... # type: ignore
class BufferedRWPair(BufferedIOBase):
def __init__(self, reader: RawIOBase, writer: RawIOBase,

View File

@@ -92,7 +92,7 @@ class LZMAFile(io.BufferedIOBase, IO[bytes]):
def peek(self, size: int = ...) -> bytes: ...
def read(self, size: Optional[int] = ...) -> bytes: ...
def read1(self, size: int = ...) -> bytes: ...
def readline(self, size: int = ...) -> bytes: ...
def readline(self, size: Optional[int] = ...) -> bytes: ...
def write(self, data: bytes) -> int: ...
def seek(self, offset: int, whence: int = ...) -> int: ...
def tell(self) -> int: ...

View File

@@ -25,8 +25,6 @@ ctypes.CDLL.__init__
fractions.Fraction.__new__ # private _normalize param was made keyword-only in Python 3.6
importlib.metadata
importlib.resources
io.BufferedRandom.read1
io.BufferedReader.read1
io.StringIO.readline
ipaddress._BaseNetwork.__init__
json.dump

View File

@@ -23,8 +23,6 @@ email.message.MIMEPart.as_string
enum.Enum._generate_next_value_
importlib.metadata
importlib.resources
io.BufferedRandom.read1
io.BufferedReader.read1
io.StringIO.readline
ipaddress._BaseNetwork.__init__
json.loads

View File

@@ -256,6 +256,7 @@ io.BufferedReader.truncate
io.BufferedWriter.seek
io.BufferedWriter.truncate
io.BytesIO.readlines
io.BytesIO.seek # Parameter name for a positional-only param differs from its name in the inherited method
io.FileIO.seek
io.StringIO.seek
io.StringIO.truncate