@@ -33,10 +33,10 @@ class _IOBase:
3333 def readable (self ) -> bool : ...
3434 read : Callable [..., Any ]
3535 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 : ...
3737 def seekable (self ) -> bool : ...
3838 def tell (self ) -> int : ...
39- def truncate (self , size : int | None = ... , / ) -> int : ...
39+ def truncate (self , size : int | None = None , / ) -> int : ...
4040 def writable (self ) -> bool : ...
4141 write : Callable [..., Any ]
4242 def writelines (self , lines : Iterable [ReadableBuffer ], / ) -> None : ...
@@ -59,8 +59,8 @@ class _BufferedIOBase(_IOBase):
5959 def readinto (self , buffer : WriteableBuffer , / ) -> int : ...
6060 def write (self , buffer : ReadableBuffer , / ) -> int : ...
6161 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 : ...
6464
6565class FileIO (RawIOBase , _RawIOBase , BinaryIO ): # type: ignore[misc] # incompatible definitions of writelines in the base classes
6666 mode : str
@@ -69,30 +69,38 @@ class FileIO(RawIOBase, _RawIOBase, BinaryIO): # type: ignore[misc] # incompat
6969 # "name" is a str. In the future, making FileIO generic might help.
7070 name : Any
7171 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
7373 ) -> None : ...
7474 @property
7575 def closefd (self ) -> bool : ...
76+ def seek (self , pos : int , whence : int = 0 , / ) -> int : ...
77+ def read (self , size : int | None = - 1 , / ) -> bytes | MaybeNone : ...
7678
7779class 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 : ...
7981 # BytesIO does not contain a "name" field. This workaround is necessary
8082 # to allow BytesIO sub-classes to add this field, as it is defined
8183 # as a read-only property on IO[].
8284 name : Any
8385 def getvalue (self ) -> bytes : ...
8486 def getbuffer (self ) -> memoryview : ...
8587 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 : ...
8690
8791class BufferedReader (BufferedIOBase , _BufferedIOBase , BinaryIO ): # type: ignore[misc] # incompatible definitions of methods in the base classes
8892 raw : RawIOBase
8993 def __init__ (self , raw : RawIOBase , buffer_size : int = 8192 ) -> None : ...
9094 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 : ...
9197
9298class BufferedWriter (BufferedIOBase , _BufferedIOBase , BinaryIO ): # type: ignore[misc] # incompatible definitions of writelines in the base classes
9399 raw : RawIOBase
94100 def __init__ (self , raw : RawIOBase , buffer_size : int = 8192 ) -> None : ...
95101 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 : ...
96104
97105class BufferedRandom (BufferedIOBase , _BufferedIOBase , BinaryIO ): # type: ignore[misc] # incompatible definitions of methods in the base classes
98106 mode : str
@@ -101,10 +109,11 @@ class BufferedRandom(BufferedIOBase, _BufferedIOBase, BinaryIO): # type: ignore
101109 def __init__ (self , raw : RawIOBase , buffer_size : int = 8192 ) -> None : ...
102110 def seek (self , target : int , whence : int = 0 , / ) -> int : ... # stubtest needs this
103111 def peek (self , size : int = 0 , / ) -> bytes : ...
112+ def truncate (self , pos : int | None = None , / ) -> int : ...
104113
105114class BufferedRWPair (BufferedIOBase , _BufferedIOBase ):
106115 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 : ...
108117
109118class _TextIOBase (_IOBase ):
110119 encoding : str
@@ -115,9 +124,9 @@ class _TextIOBase(_IOBase):
115124 def detach (self ) -> BinaryIO : ...
116125 def write (self , s : str , / ) -> int : ...
117126 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]
119128 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 : ...
121130
122131@type_check_only
123132class _WrappedBuffer (Protocol ):
@@ -177,19 +186,22 @@ class TextIOWrapper(TextIOBase, _TextIOBase, TextIO, Generic[_BufferT_co]): # t
177186 # TextIOWrapper's version of seek only supports a limited subset of
178187 # operations.
179188 def seek (self , cookie : int , whence : int = 0 , / ) -> int : ...
189+ def truncate (self , pos : int | None = None , / ) -> int : ...
180190
181191class 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 : ...
183193 # StringIO does not contain a "name" field. This workaround is necessary
184194 # to allow StringIO sub-classes to add this field, as it is defined
185195 # as a read-only property on IO[].
186196 name : Any
187197 def getvalue (self ) -> str : ...
188198 @property
189199 def line_buffering (self ) -> bool : ...
200+ def seek (self , pos : int , whence : int = 0 , / ) -> int : ...
201+ def truncate (self , pos : int | None = None , / ) -> int : ...
190202
191203class 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 : ...
193205 def decode (self , input : ReadableBuffer | str , final : bool = False ) -> str : ...
194206 @property
195207 def newlines (self ) -> str | tuple [str , ...] | None : ...
0 commit comments