Skip to content

Commit 2c859e3

Browse files
gh-85864: io docs: Add missing position-only parameters (GH-91950)
(cherry picked from commit 3a8e2b6) Co-authored-by: slateny <[email protected]>
1 parent 3d0a5f7 commit 2c859e3

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

Doc/library/io.rst

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ I/O Base Classes
320320
Note that it's already possible to iterate on file objects using ``for
321321
line in file: ...`` without calling ``file.readlines()``.
322322

323-
.. method:: seek(offset, whence=SEEK_SET)
323+
.. method:: seek(offset, whence=SEEK_SET, /)
324324

325325
Change the stream position to the given byte *offset*. *offset* is
326326
interpreted relative to the position indicated by *whence*. The default
@@ -352,7 +352,7 @@ I/O Base Classes
352352

353353
Return the current stream position.
354354

355-
.. method:: truncate(size=None)
355+
.. method:: truncate(size=None, /)
356356

357357
Resize the stream to the given *size* in bytes (or the current position
358358
if *size* is not specified). The current stream position isn't changed.
@@ -369,7 +369,7 @@ I/O Base Classes
369369
Return ``True`` if the stream supports writing. If ``False``,
370370
:meth:`write` and :meth:`truncate` will raise :exc:`OSError`.
371371

372-
.. method:: writelines(lines)
372+
.. method:: writelines(lines, /)
373373

374374
Write a list of lines to the stream. Line separators are not added, so it
375375
is usual for each of the lines provided to have a line separator at the
@@ -413,15 +413,15 @@ I/O Base Classes
413413
Read and return all the bytes from the stream until EOF, using multiple
414414
calls to the stream if necessary.
415415

416-
.. method:: readinto(b)
416+
.. method:: readinto(b, /)
417417

418418
Read bytes into a pre-allocated, writable
419419
:term:`bytes-like object` *b*, and return the
420420
number of bytes read. For example, *b* might be a :class:`bytearray`.
421421
If the object is in non-blocking mode and no bytes
422422
are available, ``None`` is returned.
423423

424-
.. method:: write(b)
424+
.. method:: write(b, /)
425425

426426
Write the given :term:`bytes-like object`, *b*, to the
427427
underlying raw stream, and return the number of
@@ -478,7 +478,7 @@ I/O Base Classes
478478

479479
.. versionadded:: 3.1
480480

481-
.. method:: read(size=-1)
481+
.. method:: read(size=-1, /)
482482

483483
Read and return up to *size* bytes. If the argument is omitted, ``None``,
484484
or negative, data is read and returned until EOF is reached. An empty
@@ -493,7 +493,7 @@ I/O Base Classes
493493
A :exc:`BlockingIOError` is raised if the underlying raw stream is in
494494
non blocking-mode, and has no data available at the moment.
495495

496-
.. method:: read1([size])
496+
.. method:: read1(size=-1, /)
497497

498498
Read and return up to *size* bytes, with at most one call to the
499499
underlying raw stream's :meth:`~RawIOBase.read` (or
@@ -528,7 +528,7 @@ I/O Base Classes
528528

529529
.. versionadded:: 3.5
530530

531-
.. method:: write(b)
531+
.. method:: write(b, /)
532532

533533
Write the given :term:`bytes-like object`, *b*, and return the number
534534
of bytes written (always equal to the length of *b* in bytes, since if
@@ -611,7 +611,7 @@ Buffered Streams
611611
Buffered I/O streams provide a higher-level interface to an I/O device
612612
than raw I/O does.
613613

614-
.. class:: BytesIO([initial_bytes])
614+
.. class:: BytesIO(initial_bytes=b'')
615615

616616
A binary stream using an in-memory bytes buffer. It inherits
617617
:class:`BufferedIOBase`. The buffer is discarded when the
@@ -646,14 +646,14 @@ than raw I/O does.
646646
Return :class:`bytes` containing the entire contents of the buffer.
647647

648648

649-
.. method:: read1([size], /)
649+
.. method:: read1(size=-1, /)
650650

651651
In :class:`BytesIO`, this is the same as :meth:`~BufferedIOBase.read`.
652652

653653
.. versionchanged:: 3.7
654654
The *size* argument is now optional.
655655

656-
.. method:: readinto1(b)
656+
.. method:: readinto1(b, /)
657657

658658
In :class:`BytesIO`, this is the same as :meth:`~BufferedIOBase.readinto`.
659659

@@ -676,18 +676,18 @@ than raw I/O does.
676676
:class:`BufferedReader` provides or overrides these methods in addition to
677677
those from :class:`BufferedIOBase` and :class:`IOBase`:
678678

679-
.. method:: peek([size])
679+
.. method:: peek(size=0, /)
680680

681681
Return bytes from the stream without advancing the position. At most one
682682
single read on the raw stream is done to satisfy the call. The number of
683683
bytes returned may be less or more than requested.
684684

685-
.. method:: read([size])
685+
.. method:: read(size=-1, /)
686686

687687
Read and return *size* bytes, or if *size* is not given or negative, until
688688
EOF or if the read call would block in non-blocking mode.
689689

690-
.. method:: read1([size])
690+
.. method:: read1(size=-1, /)
691691

692692
Read and return up to *size* bytes with only one call on the raw stream.
693693
If at least one byte is buffered, only buffered bytes are returned.
@@ -819,14 +819,14 @@ Text I/O
819819
Read and return at most *size* characters from the stream as a single
820820
:class:`str`. If *size* is negative or ``None``, reads until EOF.
821821

822-
.. method:: readline(size=-1)
822+
.. method:: readline(size=-1, /)
823823

824824
Read until newline or EOF and return a single ``str``. If the stream is
825825
already at EOF, an empty string is returned.
826826

827827
If *size* is specified, at most *size* characters will be read.
828828

829-
.. method:: seek(offset, whence=SEEK_SET)
829+
.. method:: seek(offset, whence=SEEK_SET, /)
830830

831831
Change the stream position to the given *offset*. Behaviour depends on
832832
the *whence* parameter. The default value for *whence* is
@@ -853,7 +853,7 @@ Text I/O
853853
does not usually represent a number of bytes in the underlying
854854
binary storage.
855855

856-
.. method:: write(s)
856+
.. method:: write(s, /)
857857

858858
Write the string *s* to the stream and return the number of characters
859859
written.

0 commit comments

Comments
 (0)