A couple fixes to the io stubs. (#1811)

1. The 'name' argument to FileIO.init can be either a string or an integer: https://docs.python.org/2/library/io.html#io.FileIO
2. An mmap.mmap object can be used in most places that a bytearray can: https://docs.python.org/3.5/library/mmap.html
This commit is contained in:
rchen152
2018-01-04 16:14:38 -08:00
committed by Matthias Kramm
parent fb2c7b34e2
commit f6b60cb3ea
3 changed files with 13 additions and 8 deletions

View File

@@ -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):