1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
|
# Stubs for io
from typing import (
List, BinaryIO, TextIO, Iterator, Union, Optional, Callable, Tuple, Any, IO
)
import builtins
import codecs
import sys
from types import TracebackType
DEFAULT_BUFFER_SIZE = ... # type: int
SEEK_SET = ... # type: int
SEEK_CUR = ... # type: int
SEEK_END = ... # type: int
open = builtins.open
# FIXME when mypy handle condtional, we can uncomment the next block and remove
# the temporary fix
# if sys.version_info >= (3, 3):
# BlockingIOError = BlockingIOError
# class UnsupportedOperation(OSError, ValueError): ...
# else:
# class BlockingIOError(IOError):
# characters_written = ... # type: int
# class UnsupportedOperation(IOError, ValueError): ...
class BlockingIOError(OSError):
characters_written = ... # type: int
class UnsupportedOperation(OSError, ValueError): ...
class IOBase:
def __iter__(self) -> Iterator[bytes]: ...
def __next__(self) -> bytes: ...
def __enter__(self) -> 'IOBase': ...
def __exit__(self, exc_type: Optional[type], exc_val: Optional[Exception],
exc_tb: Optional[TracebackType]) -> bool: ...
def close(self) -> None: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def readable(self) -> bool: ...
def readlines(self, hint: int = ...) -> List[bytes]: ...
def seek(self, offset: int, whence: int = ...) -> int: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def truncate(self, size: Optional[int] = ...) -> int: ...
def writable(self) -> bool: ...
def writelines(self, lines: List[Union[bytes, bytearray]]) -> None: ...
if sys.version_info >= (3, 4):
def readline(self, size: int = ...) -> bytes: ...
def __del__(self) -> None: ...
else:
def readline(self, limit: int = ...) -> bytes: ...
if sys.version_info >= (3, 2):
closed = ... # type: bool
else:
def closed(self) -> bool: ...
class RawIOBase(IOBase):
def readall(self) -> bytes: ...
def readinto(self, b: bytearray) -> Optional[int]: ...
def write(self, b: Union[bytes, bytearray]) -> Optional[int]: ...
if sys.version_info >= (3, 4):
def read(self, size: int = ...) -> Optional[bytes]: ...
else:
def read(self, n: int = ...) -> Optional[bytes]: ...
class BufferedIOBase(IOBase):
def detach(self) -> RawIOBase: ...
def readinto(self, b: bytearray) -> int: ...
def write(self, b: Union[bytes, bytearray]) -> int: ...
if sys.version_info >= (3, 5):
def readinto1(self, b: bytearray) -> int: ...
if sys.version_info >= (3, 4):
def read(self, size: Optional[int] = ...) -> bytes: ...
def read1(self, size: int = ...) -> bytes: ...
else:
def read(self, n: Optional[int] = ...) -> bytes: ...
def read1(self, n: int = ...) -> bytes: ...
class FileIO(RawIOBase):
mode = ... # type: str
name = ... # type: Union[int, str]
if sys.version_info >= (3, 3):
def __init__(
self,
name: Union[str, bytes, int],
mode: str = ...,
closefd: bool = ...,
opener: Optional[Callable[[Union[int, str], str], int]] = ...
) -> None: ...
else:
def __init__(self, name: Union[str, bytes, int],
mode: str = ..., closefd: bool = ...) -> None: ...
# TODO should extend from BufferedIOBase
class BytesIO(BinaryIO):
def __init__(self, initial_bytes: bytes = ...) -> None: ...
def getvalue(self) -> bytes: ...
if sys.version_info >= (3, 2):
def getbuffer(self) -> memoryview: ...
# copied from IOBase
def __iter__(self) -> Iterator[bytes]: ...
def __next__(self) -> bytes: ...
def __enter__(self) -> 'BytesIO': ...
def __exit__(self, t: type = None, value: BaseException = None,
traceback: Any = None) -> bool: ...
def close(self) -> None: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def readable(self) -> bool: ...
def readlines(self, hint: int = ...) -> List[bytes]: ...
def seek(self, offset: int, whence: int = ...) -> int: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def truncate(self, size: Optional[int] = ...) -> int: ...
def writable(self) -> bool: ...
# TODO should be the next line instead
# def writelines(self, lines: List[Union[bytes, bytearray]]) -> None: ...
def writelines(self, lines: Any) -> None: ...
if sys.version_info >= (3, 4):
def readline(self, size: int = ...) -> bytes: ...
def __del__(self) -> None: ...
else:
def readline(self, limit: int = ...): ...
if sys.version_info >= (3, 2):
closed = ... # type: bool
else:
def closed(self) -> bool: ...
# copied from BufferedIOBase
def detach(self) -> RawIOBase: ...
def readinto(self, b: bytearray) -> int: ...
def write(self, b: Union[bytes, bytearray]) -> int: ...
if sys.version_info >= (3, 5):
def readinto1(self, b: bytearray) -> int: ...
if sys.version_info >= (3, 4):
def read(self, size: Optional[int] = ...) -> bytes: ...
def read1(self, size: int = ...) -> bytes: ...
else:
def read(self, n: Optional[int] = ...) -> bytes: ...
def read1(self, n: int = ...) -> bytes: ...
class BufferedReader(BufferedIOBase):
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
if sys.version_info >= (3, 4):
def peek(self, size: int = ...) -> bytes: ...
else:
def peek(self, n: int = ...) -> bytes: ...
class BufferedWriter(BufferedIOBase):
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
def flush(self) -> None: ...
def write(self, b: Union[bytes, bytearray]) -> int: ...
class BufferedRandom(BufferedReader, BufferedWriter):
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
def seek(self, offset: int, whence: int = ...) -> int: ...
def tell(self) -> int: ...
class BufferedRWPair(BufferedIOBase):
def __init__(self, reader: RawIOBase, writer: RawIOBase,
buffer_size: int = ...) -> None: ...
class TextIOBase(IOBase):
encoding = ... # type: str
errors = ... # type: Optional[str]
newlines = ... # type: Union[str, Tuple[str, ...], None]
def __iter__(self) -> Iterator[str]: ... # type: ignore
def __next__(self) -> str: ... # type: ignore
def __enter__(self) -> 'TextIOBase': ...
def detach(self) -> IOBase: ...
def write(self, s: str) -> int: ...
if sys.version_info >= (3, 4):
def readline(self, size: int = ...) -> str: ... # type: ignore
def read(self, size: Optional[int] = ...) -> str: ...
elif sys.version_info >= (3, 2):
def readline(self, limit: int = ...) -> str: ... # type: ignore
else:
def readline(self) -> str: ...
if sys.version_info >= (3, 2):
def seek(self, offset: int, whence: int = ...) -> int: ...
def tell(self) -> int: ...
# TODO should extend from TextIOBase
class TextIOWrapper(TextIO):
line_buffering = ... # type: bool
# TODO uncomment after fixing mypy about using write_through
# if sys.version_info >= (3, 3):
# def __init__(self, buffer: IO[bytes], encoding: str = ...,
# errors: Optional[str] = ..., newline: Optional[str] = ...,
# line_buffering: bool = ..., write_through: bool = ...) \
# -> None: ...
# else:
# def __init__(self, buffer: IO[bytes],
# encoding: str = ..., errors: Optional[str] = ...,
# newline: Optional[str] = ..., line_buffering: bool = ...) \
# -> None: ...
def __init__(
self,
buffer: IO[bytes],
encoding: str = ...,
errors: Optional[str] = ...,
newline: Optional[str] = ...,
line_buffering: bool = ...,
write_through: bool = ...
) -> None: ...
# copied from IOBase
def __exit__(self, t: type = None, value: BaseException = None,
traceback: Any = None) -> bool: ...
def close(self) -> None: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def readable(self) -> bool: ...
def readlines(self, hint: int = ...) -> List[str]: ...
def seekable(self) -> bool: ...
def truncate(self, size: Optional[int] = ...) -> int: ...
def writable(self) -> bool: ...
# TODO should be the next line instead
# def writelines(self, lines: List[str]) -> None: ...
def writelines(self, lines: Any) -> None: ...
if sys.version_info >= (3, 4):
def __del__(self) -> None: ...
if sys.version_info >= (3, 2):
closed = ... # type: bool
else:
def closed(self) -> bool: ...
# copied from TextIOBase
encoding = ... # type: str
errors = ... # type: Optional[str]
newlines = ... # type: Union[str, Tuple[str, ...], None]
def __iter__(self) -> Iterator[str]: ...
def __next__(self) -> str: ...
def __enter__(self) -> 'TextIO': ...
def detach(self) -> IOBase: ...
def write(self, s: str) -> int: ...
if sys.version_info >= (3, 4):
def readline(self, size: int = ...) -> str: ...
def read(self, size: Optional[int] = ...) -> str: ...
elif sys.version_info >= (3, 2):
def readline(self, limit: int = ...) -> str: ...
else:
def readline(self) -> str: ...
if sys.version_info >= (3, 2):
def seek(self, offset: int, whence: int = ...) -> int: ...
def tell(self) -> int: ...
class StringIO(TextIOWrapper):
def __init__(self, initial_value: str = ...,
newline: Optional[str] = ...) -> None: ...
name = ... # type: str
def getvalue(self) -> str: ...
class IncrementalNewlineDecoder(codecs.IncrementalDecoder): ...
|