8000 Fix docs formatting · python/cpython@7867ec1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7867ec1

Browse files
committed
Fix docs formatting
1 parent 1525e05 commit 7867ec1

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

Doc/library/typing.rst

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2820,22 +2820,30 @@ are especially useful for annotating function and method arguments and are
28202820
decorated with :func:`@runtime_checkable <runtime_checkable>`.
28212821

28222822
.. class:: Reader[T]
2823+
2824+
Protocol for reading from a file or other I/O stream.
2825+
28232826
.. method:: read(size=...)
28242827
.. method:: readline(size=...)
28252828
.. method:: __iter__()
28262829

2830+
For example::
2831+
2832+
def read_it(reader: Reader[str]):
2833+
assert reader.read(11) == "--marker--\n"
2834+
for line in reader:
2835+
print(line)
2836+
28272837
.. class:: Writer[T]
2828-
.. method:: write(o)
28292838

2830-
For example::
2839+
Protocol for writing to a file or other I/O stream.
28312840

2832-
def read_it(reader: Reader[str]):
2833-
assert reader.read(11) == "--marker--\n"
2834-
for line in reader:
2835-
print(line)
2841+
.. method:: write(o)
2842+
2843+
For example::
28362844

2837-
def write_binary(writer: Writer[bytes]):
2838-
writer.write(b"Hello world!\n")
2845+
def write_binary(writer: Writer[bytes]):
2846+
writer.write(b"Hello world!\n")
28392847

28402848
Also consider using :class:`collections.abc.Iterable` for iterating over
28412849
a stream::

0 commit comments

Comments
 (0)
0