Skip to content

Commit c644770

Browse files
srittauAlexWaygood
andauthored
Doc fixes
Co-authored-by: Alex Waygood <[email protected]>
1 parent 43e23f0 commit c644770

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

Doc/library/io.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,8 +1165,9 @@ with :deco:`typing.runtime_checkable`.
11651165
.. method:: read()
11661166
read(size, /)
11671167

1168-
Read data from the input stream and return it. If ``size`` is
1169-
specified, at most ``size`` items (bytes/characters) will be read.
1168+
Read data from the input stream and return it. If *size* is
1169+
specified, it should be an integer, and at most *size* items
1170+
(bytes/characters) will be read.
11701171

11711172
For example::
11721173

@@ -1184,16 +1185,16 @@ with :deco:`typing.runtime_checkable`.
11841185

11851186
.. method:: write(data, /)
11861187

1187-
Write data to the output stream and return number of items
1188+
Write *data* to the output stream and return the number of items
11881189
(bytes/characters) written.
11891190

11901191
For example::
11911192

11921193
def write_binary(writer: Writer[bytes]):
11931194
writer.write(b"Hello world!\n")
11941195

1195-
See :ref:`typing-io` for other I/O related protocols and classes used for
1196-
static type checking.
1196+
See :ref:`typing-io` for other I/O related protocols and classes that can be
1197+
used for static type checking.
11971198

11981199
Performance
11991200
-----------

Doc/library/typing.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,16 +2822,16 @@ The protocols :class:`io.Reader` and :class:`io.Writer` offer a simpler
28222822
alternative for argument types, when only the ``read()`` or ``write()``
28232823
methods are accessed, respectively::
28242824

2825-
def read_and_write(reader: Reader[str], writer: Writer[bytes]):
2826-
data = reader.read()
2827-
writer.write(data.encode())
2825+
def read_and_write(reader: Reader[str], writer: Writer[bytes]):
2826+
data = reader.read()
2827+
writer.write(data.encode())
28282828

28292829
Also consider using :class:`collections.abc.Iterable` for iterating over
28302830
the lines of an input stream::
28312831

2832-
def read_config(stream: Iterable[str]):
2833-
for line in stream:
2834-
...
2832+
def read_config(stream: Iterable[str]):
2833+
for line in stream:
2834+
...
28352835

28362836
Functions and decorators
28372837
------------------------

Lib/io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class Reader(metaclass=abc.ABCMeta):
119119
def read(self, size=..., /):
120120
"""Read data from the input stream and return it.
121121
122-
If "size" is specified, at most "size" items (bytes/characters) will be
122+
If *size* is specified, at most *size* items (bytes/characters) will be
123123
read.
124124
"""
125125

@@ -142,7 +142,7 @@ class Writer(metaclass=abc.ABCMeta):
142142

143143
@abc.abstractmethod
144144
def write(self, data, /):
145-
"""Write data to the output stream and return number of items written."""
145+
"""Write *data* to the output stream and return the number of items written."""
146146

147147
@classmethod
148148
def __subclasshook__(cls, C):

0 commit comments

Comments
 (0)