1
1
# Stubs for io
2
2
3
- # Based on http://docs.python.org/3.2/library/io.html
4
-
5
- from typing import List , BinaryIO , TextIO , IO , overload , Iterator , Iterable , Any
3
+ from typing import (
4
+ List , BinaryIO , TextIO , IO , overload , Iterator , Iterable , Any , Union , Tuple ,
5
+ Optional , Callable
6
+ )
6
7
import builtins
7
8
import codecs
8
- import _io
9
+ from types import TracebackType
9
10
10
- DEFAULT_BUFFER_SIZE = 0 # type: int
11
+ DEFAULT_BUFFER_SIZE = ... # type: int
11
12
SEEK_SET = ... # type: int
12
13
SEEK_CUR = ... # type: int
13
14
SEEK_END = ... # type: int
@@ -17,134 +18,101 @@ open = builtins.open
17
18
class BlockingIOError (OSError ): ...
18
19
class UnsupportedOperation (ValueError , OSError ): ...
19
20
20
- class IncrementalNewlineDecoder (codecs .IncrementalDecoder ):
21
- newlines = ... # type: Any
22
- def __init__ (self , * args , ** kwargs ) -> None : ...
23
- def decode (self , input , final = ...): ...
24
- def getstate (self ): ...
25
- def reset (self ): ...
26
- def setstate (self , state ): ...
27
-
28
- class IOBase (_io ._IOBase ): ...
29
- class RawIOBase (_io ._RawIOBase , IOBase ): ...
30
- class BufferedIOBase (_io ._BufferedIOBase , IOBase ): ...
31
- class TextIOBase (_io ._TextIOBase , IOBase ): ...
32
-
33
- class FileIO (_io ._RawIOBase ):
34
- closefd = ... # type: Any
35
- mode = ... # type: Any
36
- def __init__ (self , name , mode = ..., closefd = ..., opener = ...) -> None : ...
37
- def readinto (self , b ): ...
38
- def write (self , b ): ...
39
-
40
- class BufferedReader (_io ._BufferedIOBase ):
41
- mode = ... # type: Any
42
- name = ... # type: Any
43
- raw = ... # type: Any
44
- def __init__ (self , raw , buffer_size = ...) -> None : ...
45
- def peek (self , size : int = ...): ...
46
-
47
- class BufferedWriter (_io ._BufferedIOBase ):
48
- mode = ... # type: Any
49
- name = ... # type: Any
50
- raw = ... # type: Any
51
- def __init__ (self , raw , buffer_size = ...) -> None : ...
52
-
53
- class BufferedRWPair (_io ._BufferedIOBase ):
54
- def __init__ (self , reader , writer , buffer_size = ...) -> None : ...
55
- def peek (self , size : int = ...): ...
56
-
57
- class BufferedRandom (_io ._BufferedIOBase ):
58
- mode = ... # type: Any
59
- name = ... # type: Any
60
- raw = ... # type: Any
61
- def __init__ (self , raw , buffer_size = ...) -> None : ...
62
- def peek (self , size : int = ...): ...
63
21
64
- class BytesIO (BinaryIO ):
65
- def __init__ (self , initial_bytes : bytes = ...) -> None : ...
66
- # TODO getbuffer
67
- # TODO see comments in BinaryIO for missing functionality
68
- def close (self ) -> None : ...
22
+ class IOBase :
69
23
@property
24
+ def close (self ) -> None : ...
70
25
def closed (self ) -> bool : ...
71
26
def fileno (self ) -> int : ...
72
27
def flush (self ) -> None : ...
73
28
def isatty (self ) -> bool : ...
74
- def read (self , n : int = ...) -> bytes : ...
75
29
def readable (self ) -> bool : ...
76
- def readline (self , limit : int = ...) -> bytes : ...
77
- def readlines (self , hint : int = ...) -> List [bytes ]: ...
30
+ def readline (self , size : int = ...) -> bytes : ...
31
+ def readlines (self , hint : int = ...) -> List [bytes ]: ...
78
32
def seek (self , offset : int , whence : int = ...) -> int : ...
79
33
def seekable (self ) -> bool : ...
80
34
def tell (self ) -> int : ...
81
35
def truncate (self , size : int = ...) -> int : ...
82
36
def writable (self ) -> bool : ...
83
- @overload
84
- def write (self , s : bytes ) -> int : ...
85
- @overload
86
- def write (self , s : bytearray ) -> int : ...
87
- def writelines (self , lines : Iterable [bytes ]) -> None : ...
88
- def getvalue (self ) -> bytes : ...
89
- def read1 (self ) -> str : ...
37
+ def writelines (self , lines : bytes ) -> None : ...
38
+ def __del__ (self ) -> None : ...
90
39
40
+ def __enter__ (self ) -> 'IOBase' : ...
41
+ def __exit__ (self , exc_type : Optional [type ], exc_val : Optional [Exception ],
42
+ exc_tb : Optional [TracebackType ]) -> bool : ...
91
43
def __iter__ (self ) -> Iterator [bytes ]: ...
92
- def __enter__ (self ) -> 'BytesIO' : ...
93
- def __exit__ (self , t : type = None , value : BaseException = None , traceback : Any = None ) -> bool : ...
44
+ def __next__ (self ) -> bytes : ...
94
45
95
- class StringIO (TextIO ):
96
- def __init__ (self , initial_value : str = ...,
97
- newline : str = ...) -> None : ...
98
- # TODO see comments in BinaryIO for missing functionality
99
- def close (self ) -> None : ...
100
- @property
101
- def closed (self ) -> bool : ...
102
- def fileno (self ) -> int : ...
46
+ class RawIOBase (IOBase ):
47
+ def read (self , size : int = ...) -> Optional [bytes ]: ...
48
+ def readall (self ) -> bytes : ...
49
+ def readinto (self , b : bytearray ) -> Optional [int ]: ...
50
+ def write (self , b : Union [bytes , bytearray ]) -> Optional [int ]: ...
51
+
52
+ class BufferedIOBase (IOBase ):
53
+ def detach (self ) -> 'RawIOBase' : ...
54
+ def read (self , size : Optional [int ] = ...) -> bytes : ...
55
+ def read1 (self , size : int = ...) -> bytes : ...
56
+ def readinto (self , b : bytearray ) -> int : ...
57
+ def write (self , b : Union [bytes , bytearray ]) -> int : ...
58
+
59
+
60
+ class FileIO (RawIOBase ):
61
+ mode = ... # type: str
62
+ name = ... # type: Union[int, str]
63
+ def __init__ (self , name : Union [int , str ], mode : str = ...,
64
+ closefd : bool = ...,
65
+ opener : Optional [Callable [[Union [int , str ], int ], Union [TextIO , BytesIO ]]] = ...) -> None : ...
66
+
67
+
68
+ class BytesIO (BinaryIO ):
69
+ def __init__ (self , initial_bytes : bytes = ...) -> None : ...
70
+ def getbuffer (self ) -> memoryview : ...
71
+ def getvalue (self ) -> bytes : ...
72
+ def read1 (self , size : int = ...) -> Optional [bytes ]: ...
73
+ def readinto1 (self , b : bytearray ) -> int : ...
74
+
75
+ class BufferedReader (BufferedIOBase ):
76
+ def __init__ (self , raw : RawIOBase , buffer_size : int = ...) -> None : ...
77
+ def peek (self , size : int = ...) -> bytes : ...
78
+ def read (self , size : int = ...) -> bytes : ...
79
+ def read1 (self , size : int = ...) -> bytes : ...
80
+
81
+ class BufferedWriter (BufferedIOBase ):
82
+ def __init__ (self , raw : RawIOBase , buffer_size : int = ...) -> None : ...
103
83
def flush (self ) -> None : ...
104
- def isatty (self ) -> bool : ...
105
- def read (self , n : int = ...) -> str : ...
106
- def readable (self ) -> bool : ...
107
- def readline (self , limit : int = ...) -> str : ...
108
- def readlines (self , hint : int = ...) -> List [str ]: ...
84
+ def write (self , b : Union [bytes , bytearray ]) -> int : ...
85
+
86
+ class BufferedRandom (BufferedReader , BufferedWriter ):
87
+ def __init__ (self , raw : RawIOBase , buffer_size : int = ...) -> None : ...
109
88
def seek (self , offset : int , whence : int = ...) -> int : ...
110
- def seekable (self ) -> bool : ...
111
89
def tell (self ) -> int : ...
112
- def truncate (self , size : int = ...) -> int : ...
113
- def writable (self ) -> bool : ...
114
- def write (self , s : str ) -> int : ...
115
- def writelines (self , lines : Iterable [str ]) -> None : ...
116
- def getvalue (self ) -> str : ...
117
90
118
- def __iter__ ( self ) -> Iterator [ str ]: ...
119
- def __enter__ (self ) -> 'StringIO' : ...
120
- def __exit__ ( self , t : type = None , value : BaseException = None , traceback : Any = None ) -> bool : ...
91
+ class BufferedRWPair ( BufferedIOBase ):
92
+ def __init__ (self , reader : RawIOBase , writer : RawIOBase ,
93
+ buffer_size : int = ... ) -> None : ...
121
94
122
- class TextIOWrapper (TextIO ):
123
- # TODO: This is actually a base class of _io._TextIOBase.
124
- # write_through is undocumented but used by subprocess
125
- def __init__ (self , buffer : IO [bytes ], encoding : str = ...,
126
- errors : str = ..., newline : str = ...,
127
- line_buffering : bool = ...,
128
- write_through : bool = ...) -> None : ...
129
- # TODO see comments in BinaryIO for missing functionality
130
- def close (self ) -> None : ...
131
- @property
132
- def closed (self ) -> bool : ...
133
- def fileno (self ) -> int : ...
134
- def flush (self ) -> None : ...
135
- def isatty (self ) -> bool : ...
136
- def read (self , n : int = ...) -> str : ...
137
- def readable (self ) -> bool : ...
138
- def readline (self , limit : int = ...) -> str : ...
139
- def readlines (self , hint : int = ...) -> List [str ]: ...
95
+
96
+ class TextIOBase (IOBase ):
97
+ encoding = ... # type: str
98
+ errors = ... # type: Optional[str]
99
+ def detach (self ) -> IOBase : ...
100
+ def read (self , size : Optional [int ] = ...) -> str : ...
101
+ def readline (self , size : int = ...) -> str : ...
140
102
def seek (self , offset : int , whence : int = ...) -> int : ...
141
- def seekable (self ) -> bool : ...
142
103
def tell (self ) -> int : ...
143
- def truncate (self , size : int = ...) -> int : ...
144
- def writable (self ) -> bool : ...
145
104
def write (self , s : str ) -> int : ...
146
- def writelines (self , lines : Iterable [str ]) -> None : ...
147
105
148
- def __iter__ (self ) -> Iterator [str ]: ...
149
- def __enter__ (self ) -> StringIO : ...
150
- def __exit__ (self , t : type = None , value : BaseException = None , traceback : Any = None ) -> bool : ...
106
+ class TextIOWrapper (TextIOBase ):
107
+ line_buffering = ... # type: bool
108
+ def __init__ (self , buffer : BufferedIOBase , encoding : str = ...,
109
+ errors : str = ..., newline : Optional [str ] = ...,
110
+ line_buffering : bool = ...,
111
+ write_through : bool = ...) -> None : ...
112
+
113
+ class StringIO (TextIOBase ):
114
+ def __init__ (self , initial_value : str = ...,
115
+ newline : Optional [str ] = ...) -> None : ...
116
+ def getvalue (self ) -> str : ...
117
+
118
+ class IncrementalNewlineDecoder (codecs .IncrementalDecoder ): ...
0 commit comments