Format: application/octet-stream
1 from mmap import mmap
2 from types import TracebackType
3 from typing import IO, Any, AnyStr, BinaryIO, Iterable, Iterator, List, Optional, Text, TextIO, Tuple, Type, TypeVar, Union
4
5 _bytearray_like = Union[bytearray, mmap]
6
7 DEFAULT_BUFFER_SIZE: int
8
9 class BlockingIOError(IOError):
10 characters_written: int
11
12 class UnsupportedOperation(ValueError, IOError): ...
13
14 _T = TypeVar("_T")
15
16 class _IOBase(BinaryIO):
17 @property
18 def closed(self) -> bool: ...
19 def _checkClosed(self, msg: Optional[str] = ...) -> None: ... # undocumented
20 def _checkReadable(self) -> None: ...
21 def _checkSeekable(self) -> None: ...
22 def _checkWritable(self) -> None: ...
23 # All these methods are concrete here (you can instantiate this)
24 def close(self) -> None: ...
25 def fileno(self) -> int: ...
26 def flush(self) -> None: ...
27 def isatty(self) -> bool: ...
28 def readable(self) -> bool: ...
29 def seek(self, offset: int, whence: int = ...) -> int: ...
30 def seekable(self) -> bool: ...
31 def tell(self) -> int: ...
32 def truncate(self, size: Optional[int] = ...) -> int: ...
33 def writable(self) -> bool: ...
34 def __enter__(self: _T) -> _T: ...
35 def __exit__(
36 self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any]
37 ) -> Optional[bool]: ...
38 def __iter__(self: _T) -> _T: ...
39 # The parameter type of writelines[s]() is determined by that of write():
40 def writelines(self, lines: Iterable[bytes]) -> None: ...
41 # The return type of readline[s]() and next() is determined by that of read():
42 def readline(self, limit: int = ...) -> bytes: ...
43 def readlines(self, hint: int = ...) -> List[bytes]: ...
44 def next(self) -> bytes: ...
45 # These don't actually exist but we need to pretend that it does
46 # so that this class is concrete.
47 def write(self, s: bytes) -> int: ...
48 def read(self, n: int = ...) -> bytes: ...
49
50 class _BufferedIOBase(_IOBase):
51 def read1(self, n: int) -> bytes: ...
52 def read(self, size: int = ...) -> bytes: ...
53 def readinto(self, buffer: _bytearray_like) -> int: ...
54 def write(self, s: bytes) -> int: ...
55 def detach(self) -> _IOBase: ...
56
57 class BufferedRWPair(_BufferedIOBase):
58 def __init__(self, reader: _RawIOBase, writer: _RawIOBase, buffer_size: int = ..., max_buffer_size: int = ...) -> None: ...
59 def peek(self, n: int = ...) -> bytes: ...
60 def __enter__(self) -> BufferedRWPair: ...
61
62 class BufferedRandom(_BufferedIOBase):
63 mode: str
64 name: str
65 raw: _IOBase
66 def __init__(self, raw: _IOBase, buffer_size: int = ..., max_buffer_size: int = ...) -> None: ...
67 def peek(self, n: int = ...) -> bytes: ...
68
69 class BufferedReader(_BufferedIOBase):
70 mode: str
71 name: str
72 raw: _IOBase
73 def __init__(self, raw: _IOBase, buffer_size: int = ...) -> None: ...
74 def peek(self, n: int = ...) -> bytes: ...
75
76 class BufferedWriter(_BufferedIOBase):
77 name: str
78 raw: _IOBase
79 mode: str
80 def __init__(self, raw: _IOBase, buffer_size: int = ..., max_buffer_size: int = ...) -> None: ...
81
82 class BytesIO(_BufferedIOBase):
83 def __init__(self, initial_bytes: bytes = ...) -> None: ...
84 def __setstate__(self, state: Tuple[Any, ...]) -> None: ...
85 def __getstate__(self) -> Tuple[Any, ...]: ...
86 # BytesIO does not contain a "name" field. This workaround is necessary
87 # to allow BytesIO sub-classes to add this field, as it is defined
88 # as a read-only property on IO[].
89 name: Any
90 def getvalue(self) -> bytes: ...
91 def write(self, s: bytes) -> int: ...
92 def writelines(self, lines: Iterable[bytes]) -> None: ...
93 def read1(self, size: int) -> bytes: ...
94 def next(self) -> bytes: ...
95
96 class _RawIOBase(_IOBase):
97 def readall(self) -> str: ...
98 def read(self, n: int = ...) -> str: ...
99
100 class FileIO(_RawIOBase, BytesIO):
101 mode: str
102 closefd: bool
103 def __init__(self, file: Union[str, int], mode: str = ..., closefd: bool = ...) -> None: ...
104 def readinto(self, buffer: _bytearray_like) -> int: ...
105 def write(self, pbuf: str) -> int: ...
106
107 class IncrementalNewlineDecoder(object):
108 newlines: Union[str, unicode]
109 def __init__(self, decoder, translate, z=...) -> None: ...
110 def decode(self, input, final) -> Any: ...
111 def getstate(self) -> Tuple[Any, int]: ...
112 def setstate(self, state: Tuple[Any, int]) -> None: ...
113 def reset(self) -> None: ...
114
115 # Note: In the actual _io.py, _TextIOBase inherits from _IOBase.
116 class _TextIOBase(TextIO):
117 errors: Optional[str]
118 # TODO: On _TextIOBase, this is always None. But it's unicode/bytes in subclasses.
119 newlines: Union[None, unicode, bytes]
120 encoding: str
121 @property
122 def closed(self) -> bool: ...
123 def _checkClosed(self) -> None: ...
124 def _checkReadable(self) -> None: ...
125 def _checkSeekable(self) -> None: ...
126 def _checkWritable(self) -> None: ...
127 def close(self) -> None: ...
128 def detach(self) -> IO[Any]: ...
129 def fileno(self) -> int: ...
130 def flush(self) -> None: ...
131 def isatty(self) -> bool: ...
132 def next(self) -> unicode: ...
133 def read(self, size: int = ...) -> unicode: ...
134 def readable(self) -> bool: ...
135 def readline(self, limit: int = ...) -> unicode: ...
136 def readlines(self, hint: int = ...) -> list[unicode]: ...
137 def seek(self, offset: int, whence: int = ...) -> int: ...
138 def seekable(self) -> bool: ...
139 def tell(self) -> int: ...
140 def truncate(self, size: Optional[int] = ...) -> int: ...
141 def writable(self) -> bool: ...
142 def write(self, pbuf: unicode) -> int: ...
143 def writelines(self, lines: Iterable[unicode]) -> None: ...
144 def __enter__(self: _T) -> _T: ...
145 def __exit__(
146 self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any]
147 ) -> Optional[bool]: ...
148 def __iter__(self: _T) -> _T: ...
149
150 class StringIO(_TextIOBase):
151 line_buffering: bool
152 def __init__(self, initial_value: Optional[unicode] = ..., newline: Optional[unicode] = ...) -> None: ...
153 def __setstate__(self, state: Tuple[Any, ...]) -> None: ...
154 def __getstate__(self) -> Tuple[Any, ...]: ...
155 # StringIO does not contain a "name" field. This workaround is necessary
156 # to allow StringIO sub-classes to add this field, as it is defined
157 # as a read-only property on IO[].
158 name: Any
159 def getvalue(self) -> unicode: ...
160
161 class TextIOWrapper(_TextIOBase):
162 name: str
163 line_buffering: bool
164 buffer: BinaryIO
165 _CHUNK_SIZE: int
166 def __init__(
167 self,
168 buffer: IO[Any],
169 encoding: Optional[Text] = ...,
170 errors: Optional[Text] = ...,
171 newline: Optional[Text] = ...,
172 line_buffering: bool = ...,
173 write_through: bool = ...,
174 ) -> None: ...
175
176 def open(
177 file: Union[str, unicode, int],
178 mode: Text = ...,
179 buffering: int = ...,
180 encoding: Optional[Text] = ...,
181 errors: Optional[Text] = ...,
182 newline: Optional[Text] = ...,
183 closefd: bool = ...,
184 ) -> IO[Any]: ...
185