--- /dev/null
+from typing import (\r
+ List, BinaryIO, TextIO, Iterator, Union, Optional, Callable, Tuple, Type, Any, IO, Iterable\r
+)\r
+import builtins\r
+import codecs\r
+from mmap import mmap\r
+import sys\r
+from types import TracebackType\r
+from typing import TypeVar\r
+\r
+_bytearray_like = Union[bytearray, mmap]\r
+\r
+DEFAULT_BUFFER_SIZE = ... # type: int\r
+\r
+SEEK_SET = ... # type: int\r
+SEEK_CUR = ... # type: int\r
+SEEK_END = ... # type: int\r
+\r
+_T = TypeVar('_T', bound='IOBase')\r
+\r
+open = builtins.open\r
+\r
+BlockingIOError = builtins.BlockingIOError\r
+class UnsupportedOperation(OSError, ValueError): ...\r
+\r
+class IOBase:\r
+ def __iter__(self) -> Iterator[bytes]: ...\r
+ def __next__(self) -> bytes: ...\r
+ def __enter__(self: _T) -> _T: ...\r
+ def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException],\r
+ exc_tb: Optional[TracebackType]) -> bool: ...\r
+ def close(self) -> None: ...\r
+ def fileno(self) -> int: ...\r
+ def flush(self) -> None: ...\r
+ def isatty(self) -> bool: ...\r
+ def readable(self) -> bool: ...\r
+ def readlines(self, hint: int = ...) -> List[bytes]: ...\r
+ def seek(self, offset: int, whence: int = ...) -> int: ...\r
+ def seekable(self) -> bool: ...\r
+ def tell(self) -> int: ...\r
+ def truncate(self, size: Optional[int] = ...) -> int: ...\r
+ def writable(self) -> bool: ...\r
+ def writelines(self, lines: Iterable[Union[bytes, bytearray]]) -> None: ...\r
+ def readline(self, size: int = ...) -> bytes: ...\r
+ def __del__(self) -> None: ...\r
+ @property\r
+ def closed(self) -> bool: ...\r
+\r
+class RawIOBase(IOBase):\r
+ def readall(self) -> bytes: ...\r
+ def readinto(self, b: bytearray) -> Optional[int]: ...\r
+ def write(self, b: Union[bytes, bytearray]) -> Optional[int]: ...\r
+ def read(self, size: int = ...) -> Optional[bytes]: ...\r
+\r
+class BufferedIOBase(IOBase):\r
+ def detach(self) -> RawIOBase: ...\r
+ def readinto(self, b: _bytearray_like) -> int: ...\r
+ def write(self, b: Union[bytes, bytearray]) -> int: ...\r
+ if sys.version_info >= (3, 5):\r
+ def readinto1(self, b: _bytearray_like) -> int: ...\r
+ def read(self, size: Optional[int] = ...) -> bytes: ...\r
+ def read1(self, size: int = ...) -> bytes: ...\r
+\r
+\r
+class FileIO(RawIOBase):\r
+ mode = ... # type: str\r
+ name = ... # type: Union[int, str]\r
+ def __init__(\r
+ self,\r
+ name: Union[str, bytes, int],\r
+ mode: str = ...,\r
+ closefd: bool = ...,\r
+ opener: Optional[Callable[[Union[int, str], str], int]] = ...\r
+ ) -> None: ...\r
+\r
+# TODO should extend from BufferedIOBase\r
+class BytesIO(BinaryIO):\r
+ def __init__(self, initial_bytes: bytes = ...) -> None: ...\r
+ # BytesIO does not contain a "name" field. This workaround is necessary\r
+ # to allow BytesIO sub-classes to add this field, as it is defined\r
+ # as a read-only property on IO[].\r
+ name: Any\r
+ def getvalue(self) -> bytes: ...\r
+ def getbuffer(self) -> memoryview: ...\r
+ # copied from IOBase\r
+ def __iter__(self) -> Iterator[bytes]: ...\r
+ def __next__(self) -> bytes: ...\r
+ def __enter__(self) -> 'BytesIO': ...\r
+ def __exit__(self, t: Optional[Type[BaseException]] = ..., value: Optional[BaseException] = ...,\r
+ traceback: Optional[TracebackType] = ...) -> bool: ...\r
+ def close(self) -> None: ...\r
+ def fileno(self) -> int: ...\r
+ def flush(self) -> None: ...\r
+ def isatty(self) -> bool: ...\r
+ def readable(self) -> bool: ...\r
+ def readlines(self, hint: int = ...) -> List[bytes]: ...\r
+ def seek(self, offset: int, whence: int = ...) -> int: ...\r
+ def seekable(self) -> bool: ...\r
+ def tell(self) -> int: ...\r
+ def truncate(self, size: Optional[int] = ...) -> int: ...\r
+ def writable(self) -> bool: ...\r
+ # TODO should be the next line instead\r
+ # def writelines(self, lines: List[Union[bytes, bytearray]]) -> None: ...\r
+ def writelines(self, lines: Any) -> None: ...\r
+ def readline(self, size: int = ...) -> bytes: ...\r
+ def __del__(self) -> None: ...\r
+ closed = ... # type: bool\r
+ # copied from BufferedIOBase\r
+ def detach(self) -> RawIOBase: ...\r
+ def readinto(self, b: _bytearray_like) -> int: ...\r
+ def write(self, b: Union[bytes, bytearray]) -> int: ...\r
+ if sys.version_info >= (3, 5):\r
+ def readinto1(self, b: _bytearray_like) -> int: ...\r
+ def read(self, size: Optional[int] = ...) -> bytes: ...\r
+ def read1(self, size: int = ...) -> bytes: ...\r
+\r
+class BufferedReader(BufferedIOBase):\r
+ def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...\r
+ def peek(self, size: int = ...) -> bytes: ...\r
+\r
+class BufferedWriter(BufferedIOBase):\r
+ def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...\r
+ def flush(self) -> None: ...\r
+ def write(self, b: Union[bytes, bytearray]) -> int: ...\r
+\r
+class BufferedRandom(BufferedReader, BufferedWriter):\r
+ def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...\r
+ def seek(self, offset: int, whence: int = ...) -> int: ...\r
+ def tell(self) -> int: ...\r
+\r
+class BufferedRWPair(BufferedIOBase):\r
+ def __init__(self, reader: RawIOBase, writer: RawIOBase,\r
+ buffer_size: int = ...) -> None: ...\r
+\r
+\r
+class TextIOBase(IOBase):\r
+ encoding = ... # type: str\r
+ errors = ... # type: Optional[str]\r
+ newlines = ... # type: Union[str, Tuple[str, ...], None]\r
+ def __iter__(self) -> Iterator[str]: ... # type: ignore\r
+ def __next__(self) -> str: ... # type: ignore\r
+ def detach(self) -> IOBase: ...\r
+ def write(self, s: str) -> int: ...\r
+ def readline(self, size: int = ...) -> str: ... # type: ignore\r
+ def read(self, size: Optional[int] = ...) -> str: ...\r
+ def seek(self, offset: int, whence: int = ...) -> int: ...\r
+ def tell(self) -> int: ...\r
+\r
+# TODO should extend from TextIOBase\r
+class TextIOWrapper(TextIO):\r
+ line_buffering = ... # type: bool\r
+ # TODO uncomment after fixing mypy about using write_through\r
+ # def __init__(self, buffer: IO[bytes], encoding: str = ...,\r
+ # errors: Optional[str] = ..., newline: Optional[str] = ...,\r
+ # line_buffering: bool = ..., write_through: bool = ...) \\r
+ # -> None: ...\r
+ def __init__(\r
+ self,\r
+ buffer: IO[bytes],\r
+ encoding: str = ...,\r
+ errors: Optional[str] = ...,\r
+ newline: Optional[str] = ...,\r
+ line_buffering: bool = ...,\r
+ write_through: bool = ...\r
+ ) -> None: ...\r
+ # copied from IOBase\r
+ def __exit__(self, t: Optional[Type[BaseException]] = ..., value: Optional[BaseException] = ...,\r
+ traceback: Optional[TracebackType] = ...) -> bool: ...\r
+ def close(self) -> None: ...\r
+ def fileno(self) -> int: ...\r
+ def flush(self) -> None: ...\r
+ def isatty(self) -> bool: ...\r
+ def readable(self) -> bool: ...\r
+ def readlines(self, hint: int = ...) -> List[str]: ...\r
+ def seekable(self) -> bool: ...\r
+ def truncate(self, size: Optional[int] = ...) -> int: ...\r
+ def writable(self) -> bool: ...\r
+ # TODO should be the next line instead\r
+ # def writelines(self, lines: List[str]) -> None: ...\r
+ def writelines(self, lines: Any) -> None: ...\r
+ def __del__(self) -> None: ...\r
+ closed = ... # type: bool\r
+ # copied from TextIOBase\r
+ encoding = ... # type: str\r
+ errors = ... # type: Optional[str]\r
+ newlines = ... # type: Union[str, Tuple[str, ...], None]\r
+ def __iter__(self) -> Iterator[str]: ...\r
+ def __next__(self) -> str: ...\r
+ def __enter__(self) -> 'TextIO': ...\r
+ def detach(self) -> IOBase: ...\r
+ def write(self, s: str) -> int: ...\r
+ def readline(self, size: int = ...) -> str: ...\r
+ def read(self, size: Optional[int] = ...) -> str: ...\r
+ def seek(self, offset: int, whence: int = ...) -> int: ...\r
+ def tell(self) -> int: ...\r
+\r
+class StringIO(TextIOWrapper):\r
+ def __init__(self, initial_value: str = ...,\r
+ newline: Optional[str] = ...) -> None: ...\r
+ # StringIO does not contain a "name" field. This workaround is necessary\r
+ # to allow StringIO sub-classes to add this field, as it is defined\r
+ # as a read-only property on IO[].\r
+ name: Any\r
+ def getvalue(self) -> str: ...\r
+ def __enter__(self) -> 'StringIO': ...\r
+\r
+class IncrementalNewlineDecoder(codecs.IncrementalDecoder):\r
+ def decode(self, input: bytes, final: bool = ...) -> str: ...\r