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

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