@@ -33,10 +33,10 @@ class _IOBase:
33
33
def readable (self ) -> bool : ...
34
34
read : Callable [..., Any ]
35
35
def readlines (self , hint : int = - 1 , / ) -> list [bytes ]: ...
36
- def seek (self , offset : int , whence : int = ... , / ) -> int : ...
36
+ def seek (self , offset : int , whence : int = 0 , / ) -> int : ...
37
37
def seekable (self ) -> bool : ...
38
38
def tell (self ) -> int : ...
39
- def truncate (self , size : int | None = ... , / ) -> int : ...
39
+ def truncate (self , size : int | None = None , / ) -> int : ...
40
40
def writable (self ) -> bool : ...
41
41
write : Callable [..., Any ]
42
42
def writelines (self , lines : Iterable [ReadableBuffer ], / ) -> None : ...
@@ -59,8 +59,8 @@ class _BufferedIOBase(_IOBase):
59
59
def readinto (self , buffer : WriteableBuffer , / ) -> int : ...
60
60
def write (self , buffer : ReadableBuffer , / ) -> int : ...
61
61
def readinto1 (self , buffer : WriteableBuffer , / ) -> int : ...
62
- def read (self , size : int | None = ... , / ) -> bytes : ...
63
- def read1 (self , size : int = ... , / ) -> bytes : ...
62
+ def read (self , size : int | None = - 1 , / ) -> bytes : ...
63
+ def read1 (self , size : int = - 1 , / ) -> bytes : ...
64
64
65
65
class FileIO (RawIOBase , _RawIOBase , BinaryIO ): # type: ignore[misc] # incompatible definitions of writelines in the base classes
66
66
mode : str
@@ -69,30 +69,38 @@ class FileIO(RawIOBase, _RawIOBase, BinaryIO): # type: ignore[misc] # incompat
69
69
# "name" is a str. In the future, making FileIO generic might help.
70
70
name : Any
71
71
def __init__ (
72
- self , file : FileDescriptorOrPath , mode : str = ... , closefd : bool = ... , opener : _Opener | None = ...
72
+ self , file : FileDescriptorOrPath , mode : str = "r" , closefd : bool = True , opener : _Opener | None = None
73
73
) -> None : ...
74
74
@property
75
75
def closefd (self ) -> bool : ...
76
+ def seek (self , pos : int , whence : int = 0 , / ) -> int : ...
77
+ def read (self , size : int | None = - 1 , / ) -> bytes | MaybeNone : ...
76
78
77
79
class BytesIO (BufferedIOBase , _BufferedIOBase , BinaryIO ): # type: ignore[misc] # incompatible definitions of methods in the base classes
78
- def __init__ (self , initial_bytes : ReadableBuffer = ... ) -> None : ...
80
+ def __init__ (self , initial_bytes : ReadableBuffer = b"" ) -> None : ...
79
81
# BytesIO does not contain a "name" field. This workaround is necessary
80
82
# to allow BytesIO sub-classes to add this field, as it is defined
81
83
# as a read-only property on IO[].
82
84
name : Any
83
85
def getvalue (self ) -> bytes : ...
84
86
def getbuffer (self ) -> memoryview : ...
85
87
def read1 (self , size : int | None = - 1 , / ) -> bytes : ...
88
+ def readlines (self , size : int | None = None , / ) -> list [bytes ]: ...
89
+ def seek (self , pos : int , whence : int = 0 , / ) -> int : ...
86
90
87
91
class BufferedReader (BufferedIOBase , _BufferedIOBase , BinaryIO ): # type: ignore[misc] # incompatible definitions of methods in the base classes
88
92
raw : RawIOBase
89
93
def __init__ (self , raw : RawIOBase , buffer_size : int = 8192 ) -> None : ...
90
94
def peek (self , size : int = 0 , / ) -> bytes : ...
95
+ def seek (self , target : int , whence : int = 0 , / ) -> int : ...
96
+ def truncate (self , pos : int | None = None , / ) -> int : ...
91
97
92
98
class BufferedWriter (BufferedIOBase , _BufferedIOBase , BinaryIO ): # type: ignore[misc] # incompatible definitions of writelines in the base classes
93
99
raw : RawIOBase
94
100
def __init__ (self , raw : RawIOBase , buffer_size : int = 8192 ) -> None : ...
95
101
def write (self , buffer : ReadableBuffer , / ) -> int : ...
102
+ def seek (self , target : int , whence : int = 0 , / ) -> int : ...
103
+ def truncate (self , pos : int | None = None , / ) -> int : ...
96
104
97
105
class BufferedRandom (BufferedIOBase , _BufferedIOBase , BinaryIO ): # type: ignore[misc] # incompatible definitions of methods in the base classes
98
106
mode : str
@@ -101,10 +109,11 @@ class BufferedRandom(BufferedIOBase, _BufferedIOBase, BinaryIO): # type: ignore
101
109
def __init__ (self , raw : RawIOBase , buffer_size : int = 8192 ) -> None : ...
102
110
def seek (self , target : int , whence : int = 0 , / ) -> int : ... # stubtest needs this
103
111
def peek (self , size : int = 0 , / ) -> bytes : ...
112
+ def truncate (self , pos : int | None = None , / ) -> int : ...
104
113
105
114
class BufferedRWPair (BufferedIOBase , _BufferedIOBase ):
106
115
def __init__ (self , reader : RawIOBase , writer : RawIOBase , buffer_size : int = 8192 ) -> None : ...
107
- def peek (self , size : int = ... , / ) -> bytes : ...
116
+ def peek (self , size : int = 0 , / ) -> bytes : ...
108
117
109
118
class _TextIOBase (_IOBase ):
110
119
encoding : str
@@ -115,9 +124,9 @@ class _TextIOBase(_IOBase):
115
124
def detach (self ) -> BinaryIO : ...
116
125
def write (self , s : str , / ) -> int : ...
117
126
def writelines (self , lines : Iterable [str ], / ) -> None : ... # type: ignore[override]
118
- def readline (self , size : int = ... , / ) -> str : ... # type: ignore[override]
127
+ def readline (self , size : int = - 1 , / ) -> str : ... # type: ignore[override]
119
128
def readlines (self , hint : int = - 1 , / ) -> list [str ]: ... # type: ignore[override]
120
- def read (self , size : int | None = ... , / ) -> str : ...
129
+ def read (self , size : int | None = - 1 , / ) -> str : ...
121
130
122
131
@type_check_only
123
132
class _WrappedBuffer (Protocol ):
@@ -177,19 +186,22 @@ class TextIOWrapper(TextIOBase, _TextIOBase, TextIO, Generic[_BufferT_co]): # t
177
186
# TextIOWrapper's version of seek only supports a limited subset of
178
187
# operations.
179
188
def seek (self , cookie : int , whence : int = 0 , / ) -> int : ...
189
+ def truncate (self , pos : int | None = None , / ) -> int : ...
180
190
181
191
class StringIO (TextIOBase , _TextIOBase , TextIO ): # type: ignore[misc] # incompatible definitions of write in the base classes
182
- def __init__ (self , initial_value : str | None = ... , newline : str | None = ... ) -> None : ...
192
+ def __init__ (self , initial_value : str | None = "" , newline : str | None = " \n " ) -> None : ...
183
193
# StringIO does not contain a "name" field. This workaround is necessary
184
194
# to allow StringIO sub-classes to add this field, as it is defined
185
195
# as a read-only property on IO[].
186
196
name : Any
187
197
def getvalue (self ) -> str : ...
188
198
@property
189
199
def line_buffering (self ) -> bool : ...
200
+ def seek (self , pos : int , whence : int = 0 , / ) -> int : ...
201
+ def truncate (self , pos : int | None = None , / ) -> int : ...
190
202
191
203
class IncrementalNewlineDecoder :
192
- def __init__ (self , decoder : codecs .IncrementalDecoder | None , translate : bool , errors : str = ... ) -> None : ...
204
+ def __init__ (self , decoder : codecs .IncrementalDecoder | None , translate : bool , errors : str = "strict" ) -> None : ...
193
205
def decode (self , input : ReadableBuffer | str , final : bool = False ) -> str : ...
194
206
@property
195
207
def newlines (self ) -> str | tuple [str , ...] | None : ...
0 commit comments