diff --git a/stdlib/2/_io.pyi b/stdlib/2/_io.pyi index 3f1baab15..cc6a59712 100644 --- a/stdlib/2/_io.pyi +++ b/stdlib/2/_io.pyi @@ -1,6 +1,9 @@ from typing import Any, AnyStr, BinaryIO, IO, Text, TextIO, Iterable, Iterator, List, Optional, Type, Tuple, TypeVar, Union +from mmap import mmap from types import TracebackType +_bytearray_like = Union[bytearray, mmap] + DEFAULT_BUFFER_SIZE = ... # type: int class BlockingIOError(IOError): @@ -41,7 +44,7 @@ class _IOBase(BinaryIO): class _BufferedIOBase(_IOBase): def read1(self, n: int) -> bytes: ... def read(self, size: int = ...) -> bytes: ... - def readinto(self, buffer: bytearray) -> int: ... + def readinto(self, buffer: _bytearray_like) -> int: ... def write(self, s: bytes) -> int: ... def detach(self) -> _IOBase: ... @@ -92,8 +95,8 @@ class _RawIOBase(_IOBase): class FileIO(_RawIOBase, BytesIO): # type: ignore # for __enter__ mode = ... # type: str closefd = ... # type: bool - def __init__(self, file: str, mode: str = ..., closefd: bool = ...) -> None: ... - def readinto(self, buffer: bytearray)-> int: ... + def __init__(self, file: Union[str, int], mode: str = ..., closefd: bool = ...) -> None: ... + def readinto(self, buffer: _bytearray_like)-> int: ... def write(self, pbuf: str) -> int: ... class IncrementalNewlineDecoder(object): diff --git a/stdlib/3/http/client.pyi b/stdlib/3/http/client.pyi index 30f45d845..9cd465746 100644 --- a/stdlib/3/http/client.pyi +++ b/stdlib/3/http/client.pyi @@ -89,7 +89,6 @@ if sys.version_info >= (3, 5): def __init__(self, sock: socket, debuglevel: int = ..., method: Optional[str] = ..., url: Optional[str] = ...) -> None: ... def read(self, amt: Optional[int] = ...) -> bytes: ... - def readinto(self, b: bytearray) -> int: ... @overload def getheader(self, name: str) -> Optional[str]: ... @overload diff --git a/stdlib/3/io.pyi b/stdlib/3/io.pyi index ea2752dd7..f4d60329c 100644 --- a/stdlib/3/io.pyi +++ b/stdlib/3/io.pyi @@ -3,10 +3,13 @@ from typing import ( ) import builtins import codecs +from mmap import mmap import sys from types import TracebackType from typing import TypeVar +_bytearray_like = Union[bytearray, mmap] + DEFAULT_BUFFER_SIZE = ... # type: int SEEK_SET = ... # type: int @@ -65,10 +68,10 @@ class RawIOBase(IOBase): class BufferedIOBase(IOBase): def detach(self) -> RawIOBase: ... - def readinto(self, b: bytearray) -> int: ... + def readinto(self, b: _bytearray_like) -> int: ... def write(self, b: Union[bytes, bytearray]) -> int: ... if sys.version_info >= (3, 5): - def readinto1(self, b: bytearray) -> int: ... + def readinto1(self, b: _bytearray_like) -> int: ... if sys.version_info >= (3, 4): def read(self, size: Optional[int] = ...) -> bytes: ... def read1(self, size: int = ...) -> bytes: ... @@ -129,10 +132,10 @@ class BytesIO(BinaryIO): def closed(self) -> bool: ... # copied from BufferedIOBase def detach(self) -> RawIOBase: ... - def readinto(self, b: bytearray) -> int: ... + def readinto(self, b: _bytearray_like) -> int: ... def write(self, b: Union[bytes, bytearray]) -> int: ... if sys.version_info >= (3, 5): - def readinto1(self, b: bytearray) -> int: ... + def readinto1(self, b: _bytearray_like) -> int: ... if sys.version_info >= (3, 4): def read(self, size: Optional[int] = ...) -> bytes: ... def read1(self, size: int = ...) -> bytes: ...