mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-22 03:41:28 +08:00
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:
@@ -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: ...
|
||||
|
||||
Reference in New Issue
Block a user