Skip to content

Commit 3a8e2b6

Browse files
authored
pythongh-85864: io docs: Add missing position-only parameters (python#91950)
1 parent 9ea9078 commit 3a8e2b6

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
@@ -401,7 +401,7 @@ I/O Base Classes
401401
Note that it's already possible to iterate on file objects using ``for
402402
line in file: ...`` without calling ``file.readlines()``.
403403

404-
.. method:: seek(offset, whence=SEEK_SET)
404+
.. method:: seek(offset, whence=SEEK_SET, /)
405405

406406
Change the stream position to the given byte *offset*. *offset* is
407407
interpreted relative to the position indicated by *whence*. The default
@@ -433,7 +433,7 @@ I/O Base Classes
433433

434434
Return the current stream position.
435435

436-
.. method:: truncate(size=None)
436+
.. method:: truncate(size=None, /)
437437

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

453-
.. method:: writelines(lines)
453+
.. method:: writelines(lines, /)
454454

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

497-
.. method:: readinto(b)
497+
.. method:: readinto(b, /)
498498

499499
Read bytes into a pre-allocated, writable
500500
:term:`bytes-like object` *b*, and return the
501501
number of bytes read. For example, *b* might be a :class:`bytearray`.
502502
If the object is in non-blocking mode and no bytes
503503
are available, ``None`` is returned.
504504

505-
.. method:: write(b)
505+
.. method:: write(b, /)
506506

507507
Write the given :term:`bytes-like object`, *b*, to the
508508
underlying raw stream, and return the number of
@@ -559,7 +559,7 @@ I/O Base Classes
559559

560560
.. versionadded:: 3.1
561561

562-
.. method:: read(size=-1)
562+
.. method:: read(size=-1, /)
563563

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

577-
.. method:: read1([size])
577+
.. method:: read1(size=-1, /)
578578

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

610610
.. versionadded:: 3.5
611611

612-
.. method:: write(b)
612+
.. method:: write(b, /)
613613

614614
Write the given :term:`bytes-like object`, *b*, and return the number
615615
of bytes written (always equal to the length of *b* in bytes, since if
@@ -692,7 +692,7 @@ Buffered Streams
692692
Buffered I/O streams provide a higher-level interface to an I/O device
693693
than raw I/O does.
694694

695-
.. class:: BytesIO([initial_bytes])
695+
.. class:: BytesIO(initial_bytes=b'')
696696

697697
A binary stream using an in-memory bytes buffer. It inherits
698698
:class:`BufferedIOBase`. The buffer is discarded when the
@@ -727,14 +727,14 @@ than raw I/O does.
727727
Return :class:`bytes` containing the entire contents of the buffer.
728728

729729

730-
.. method:: read1([size], /)
730+
.. method:: read1(size=-1, /)
731731

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

734734
.. versionchanged:: 3.7
735735
The *size* argument is now optional.
736736

737-
.. method:: readinto1(b)
737+
.. method:: readinto1(b, /)
738738

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

@@ -757,18 +757,18 @@ than raw I/O does.
757757
:class:`BufferedReader` provides or overrides these methods in addition to
758758
those from :class:`BufferedIOBase` and :class:`IOBase`:
759759

760-
.. method:: peek([size])
760+
.. method:: peek(size=0, /)
761761

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

766-
.. method:: read([size])
766+
.. method:: read(size=-1, /)
767767

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

771-
.. method:: read1([size])
771+
.. method:: read1(size=-1, /)
772772

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

903-
.. method:: readline(size=-1)
903+
.. method:: readline(size=-1, /)
904904

905905
Read until newline or EOF and return a single ``str``. If the stream is
906906
already at EOF, an empty string is returned.
907907

908908
If *size* is specified, at most *size* characters will be read.
909909

910-
.. method:: seek(offset, whence=SEEK_SET)
910+
.. method:: seek(offset, whence=SEEK_SET, /)
911911

912912
Change the stream position to the given *offset*. Behaviour depends on
913913
the *whence* parameter. The default value for *whence* is
@@ -934,7 +934,7 @@ Text I/O
934934
does not usually represent a number of bytes in the underlying
935935
binary storage.
936936

937-
.. method:: write(s)
937+
.. method:: write(s, /)
938938

939939
Write the string *s* to the stream and return the number of characters
940940
written.

0 commit comments

Comments
 (0)