Skip to content
Merged
2 changes: 1 addition & 1 deletion stdlib/3/gzip.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,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: ...
Comment thread
tarcisioe marked this conversation as resolved.

class _GzipReader(_compression.DecompressReader):
def __init__(self, fp: IO[bytes]) -> None: ...
Expand Down
46 changes: 12 additions & 34 deletions stdlib/3/io.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,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: ...
Expand All @@ -65,7 +65,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]
Expand All @@ -77,52 +76,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: ...
Expand All @@ -133,6 +107,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,
Expand Down
2 changes: 1 addition & 1 deletion stdlib/3/lzma.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class LZMAFile(io.BufferedIOBase, IO[bytes]): # type: ignore # python/mypy#502
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: ...
Comment thread
tarcisioe marked this conversation as resolved.
def write(self, data: bytes) -> int: ...
def seek(self, offset: int, whence: int = ...) -> int: ...
def tell(self) -> int: ...
Expand Down
2 changes: 0 additions & 2 deletions tests/stubtest_whitelists/py35.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ gettext.npgettext
gettext.pgettext
importlib.metadata
importlib.resources
io.BufferedRandom.read1
io.BufferedReader.read1
io.StringIO.readline
ipaddress._BaseNetwork.__init__
json.dump
Expand Down
2 changes: 0 additions & 2 deletions tests/stubtest_whitelists/py36.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ gettext.npgettext
gettext.pgettext
importlib.metadata
importlib.resources
io.BufferedRandom.read1
io.BufferedReader.read1
io.StringIO.readline
ipaddress._BaseNetwork.__init__
json.loads
Expand Down
1 change: 1 addition & 0 deletions tests/stubtest_whitelists/py3_common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,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
Expand Down