Skip to content

Commit e0ad874

Browse files
[3.14] gh-150285: Fix too long docstrings in the asyncio package (GH-151074) (GH-151175)
(cherry picked from commit ed2b042)
1 parent 4c1f967 commit e0ad874

12 files changed

Lines changed: 125 additions & 110 deletions

File tree

Lib/asyncio/base_events.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,10 @@ def set_task_factory(self, factory):
483483
If factory is None the default task factory will be set.
484484
485485
If factory is a callable, it should have a signature matching
486-
'(loop, coro, **kwargs)', where 'loop' will be a reference to the active
487-
event loop, 'coro' will be a coroutine object, and **kwargs will be
488-
arbitrary keyword arguments that should be passed on to Task.
489-
The callable must return a Task.
486+
'(loop, coro, **kwargs)', where 'loop' will be a reference to the
487+
active event loop, 'coro' will be a coroutine object, and **kwargs
488+
will be arbitrary keyword arguments that should be passed on to
489+
Task. The callable must return a Task.
490490
"""
491491
if factory is not None and not callable(factory):
492492
raise TypeError('task factory must be a callable or None')
@@ -721,8 +721,8 @@ def run_until_complete(self, future):
721721
def stop(self):
722722
"""Stop running the event loop.
723723
724-
Every callback already scheduled will still run. This simply informs
725-
run_forever to stop looping after a complete iteration.
724+
Every callback already scheduled will still run. This simply
725+
informs run_forever to stop looping after a complete iteration.
726726
"""
727727
self._stopping = True
728728

@@ -1070,12 +1070,12 @@ async def create_connection(
10701070
10711071
Create a streaming transport connection to a given internet host and
10721072
port: socket family AF_INET or socket.AF_INET6 depending on host (or
1073-
family if specified), socket type SOCK_STREAM. protocol_factory must be
1074-
a callable returning a protocol instance.
1073+
family if specified), socket type SOCK_STREAM. protocol_factory must
1074+
be a callable returning a protocol instance.
10751075
1076-
This method is a coroutine which will try to establish the connection
1077-
in the background. When successful, the coroutine returns a
1078-
(transport, protocol) pair.
1076+
This method is a coroutine which will try to establish the
1077+
connection in the background. When successful, the coroutine
1078+
returns a (transport, protocol) pair.
10791079
"""
10801080
if server_hostname is not None and not ssl:
10811081
raise ValueError('server_hostname is only meaningful with ssl')
@@ -1542,11 +1542,11 @@ async def create_server(
15421542
The host parameter can be a string, in that case the TCP server is
15431543
bound to host and port.
15441544
1545-
The host parameter can also be a sequence of strings and in that case
1546-
the TCP server is bound to all hosts of the sequence. If a host
1547-
appears multiple times (possibly indirectly e.g. when hostnames
1548-
resolve to the same IP address), the server is only bound once to that
1549-
host.
1545+
The host parameter can also be a sequence of strings and in that
1546+
case the TCP server is bound to all hosts of the sequence. If
1547+
a host appears multiple times (possibly indirectly e.g. when
1548+
hostnames resolve to the same IP address), the server is only bound
1549+
once to that host.
15501550
15511551
Return a Server object which can be used to stop the service.
15521552

Lib/asyncio/events.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ async def create_server(
374374
375375
If host is an empty string or None all interfaces are assumed
376376
and a list of multiple sockets will be returned (most likely
377-
one for IPv4 and another one for IPv6). The host parameter can also be
378-
a sequence (e.g. list) of hosts to bind to.
377+
one for IPv4 and another one for IPv6). The host parameter can also
378+
be a sequence (e.g. list) of hosts to bind to.
379379
380380
family can be set to either AF_INET or AF_INET6 to force the
381381
socket to use IPv4 or IPv6. If not set it will be determined
@@ -415,8 +415,9 @@ async def create_server(
415415
416416
start_serving set to True (default) causes the created server
417417
to start accepting connections immediately. When set to False,
418-
the user should await Server.start_serving() or Server.serve_forever()
419-
to make the server to start accepting connections.
418+
the user should await Server.start_serving() or
419+
Server.serve_forever() to make the server to start accepting
420+
connections.
420421
"""
421422
raise NotImplementedError
422423

@@ -479,8 +480,9 @@ async def create_unix_server(
479480
480481
start_serving set to True (default) causes the created server
481482
to start accepting connections immediately. When set to False,
482-
the user should await Server.start_serving() or Server.serve_forever()
483-
to make the server to start accepting connections.
483+
the user should await Server.start_serving() or
484+
Server.serve_forever() to make the server to start accepting
485+
connections.
484486
"""
485487
raise NotImplementedError
486488

@@ -511,8 +513,8 @@ async def create_datagram_endpoint(self, protocol_factory,
511513
512514
protocol_factory must be a callable returning a protocol instance.
513515
514-
socket family AF_INET, socket.AF_INET6 or socket.AF_UNIX depending on
515-
host (or family if specified), socket type SOCK_DGRAM.
516+
socket family AF_INET, socket.AF_INET6 or socket.AF_UNIX depending
517+
on host (or family if specified), socket type SOCK_DGRAM.
516518
517519
reuse_address tells the kernel to reuse a local socket in
518520
TIME_WAIT state, without waiting for its natural timeout to
@@ -552,7 +554,8 @@ async def connect_read_pipe(self, protocol_factory, pipe):
552554
async def connect_write_pipe(self, protocol_factory, pipe):
553555
"""Register write pipe in event loop.
554556
555-
protocol_factory should instantiate object with BaseProtocol interface.
557+
protocol_factory should instantiate object with BaseProtocol
558+
interface.
556559
Pipe is file-like object already switched to nonblocking.
557560
Return pair (transport, protocol), where transport support
558561
WriteTransport interface."""

Lib/asyncio/graph.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ def capture_call_graph(
112112
optional keyword-only 'depth' argument can be used to skip the specified
113113
number of frames from top of the stack.
114114
115-
If the optional keyword-only 'limit' argument is provided, each call stack
116-
in the resulting graph is truncated to include at most ``abs(limit)``
117-
entries. If 'limit' is positive, the entries left are the closest to
118-
the invocation point. If 'limit' is negative, the topmost entries are
119-
left. If 'limit' is omitted or None, all entries are present.
120-
If 'limit' is 0, the call stack is not captured at all, only
121-
"awaited by" information is present.
115+
If the optional keyword-only 'limit' argument is provided, each call
116+
stack in the resulting graph is truncated to include at most
117+
``abs(limit)`` entries. If 'limit' is positive, the entries left are
118+
the closest to the invocation point. If 'limit' is negative, the
119+
topmost entries are left. If 'limit' is omitted or None, all entries
120+
are present. If 'limit' is 0, the call stack is not captured at all,
121+
only "awaited by" information is present.
122122
"""
123123

124124
loop = events._get_running_loop()

Lib/asyncio/locks.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ def _wake_up_first(self):
158158
class Event(mixins._LoopBoundMixin):
159159
"""Asynchronous equivalent to threading.Event.
160160
161-
Class implementing event objects. An event manages a flag that can be set
162-
to true with the set() method and reset to false with the clear() method.
163-
The wait() method blocks until the flag is true. The flag is initially
164-
false.
161+
Class implementing event objects. An event manages a flag that can be
162+
set to true with the set() method and reset to false with the clear()
163+
method. The wait() method blocks until the flag is true. The flag is
164+
initially false.
165165
"""
166166

167167
def __init__(self):
@@ -353,9 +353,9 @@ class Semaphore(_ContextManagerMixin, mixins._LoopBoundMixin):
353353
"""A Semaphore implementation.
354354
355355
A semaphore manages an internal counter which is decremented by each
356-
acquire() call and incremented by each release() call. The counter
357-
can never go below zero; when acquire() finds that it is zero, it blocks,
358-
waiting until some other thread calls release().
356+
acquire() call and incremented by each release() call. The counter
357+
can never go below zero; when acquire() finds that it is zero, it
358+
blocks, waiting until some other thread calls release().
359359
360360
Semaphores also support the context management protocol.
361361
@@ -511,8 +511,8 @@ async def __aexit__(self, *args):
511511
async def wait(self):
512512
"""Wait for the barrier.
513513
514-
When the specified number of tasks have started waiting, they are all
515-
simultaneously awoken.
514+
When the specified number of tasks have started waiting, they are
515+
all simultaneously awoken.
516516
Returns an unique and individual index number from 0 to 'parties-1'.
517517
"""
518518
async with self._cond:

Lib/asyncio/queues.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class QueueShutDown(Exception):
3333
class Queue(mixins._LoopBoundMixin):
3434
"""A queue, useful for coordinating producer and consumer coroutines.
3535
36-
If maxsize is less than or equal to zero, the queue size is infinite. If it
37-
is an integer greater than 0, then "await put()" will block when the
38-
queue reaches maxsize, until an item is removed by get().
36+
If maxsize is less than or equal to zero, the queue size is infinite.
37+
If it is an integer greater than 0, then "await put()" will block when
38+
the queue reaches maxsize, until an item is removed by get().
3939
4040
Unlike queue.Queue, you can reliably know this Queue's size
4141
with qsize(), since your single-threaded asyncio application won't be
@@ -174,8 +174,8 @@ async def get(self):
174174
175175
If queue is empty, wait until an item is available.
176176
177-
Raises QueueShutDown if the queue has been shut down and is empty, or
178-
if the queue has been shut down immediately.
177+
Raises QueueShutDown if the queue has been shut down and is empty,
178+
or if the queue has been shut down immediately.
179179
"""
180180
while self.empty():
181181
if self._is_shutdown and self.empty():
@@ -203,10 +203,11 @@ async def get(self):
203203
def get_nowait(self):
204204
"""Remove and return an item from the queue.
205205
206-
Return an item if one is immediately available, else raise QueueEmpty.
206+
Return an item if one is immediately available, else raise
207+
QueueEmpty.
207208
208-
Raises QueueShutDown if the queue has been shut down and is empty, or
209-
if the queue has been shut down immediately.
209+
Raises QueueShutDown if the queue has been shut down and is empty,
210+
or if the queue has been shut down immediately.
210211
"""
211212
if self.empty():
212213
if self._is_shutdown:
@@ -223,12 +224,12 @@ def task_done(self):
223224
a subsequent call to task_done() tells the queue that the processing
224225
on the task is complete.
225226
226-
If a join() is currently blocking, it will resume when all items have
227-
been processed (meaning that a task_done() call was received for every
228-
item that had been put() into the queue).
227+
If a join() is currently blocking, it will resume when all items
228+
have been processed (meaning that a task_done() call was received
229+
for every item that had been put() into the queue).
229230
230-
Raises ValueError if called more times than there were items placed in
231-
the queue.
231+
Raises ValueError if called more times than there were items placed
232+
in the queue.
232233
"""
233234
if self._unfinished_tasks <= 0:
234235
raise ValueError('task_done() called too many times')
@@ -239,10 +240,11 @@ def task_done(self):
239240
async def join(self):
240241
"""Block until all items in the queue have been gotten and processed.
241242
242-
The count of unfinished tasks goes up whenever an item is added to the
243-
queue. The count goes down whenever a consumer calls task_done() to
244-
indicate that the item was retrieved and all work on it is complete.
245-
When the count of unfinished tasks drops to zero, join() unblocks.
243+
The count of unfinished tasks goes up whenever an item is added to
244+
the queue. The count goes down whenever a consumer calls
245+
task_done() to indicate that the item was retrieved and all work on
246+
it is complete. When the count of unfinished tasks drops to zero,
247+
join() unblocks.
246248
"""
247249
if self._unfinished_tasks > 0:
248250
await self._finished.wait()

Lib/asyncio/runners.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class Runner:
3535
with asyncio.Runner(debug=True) as runner:
3636
runner.run(main())
3737
38-
The run() method can be called multiple times within the runner's context.
38+
The run() method can be called multiple times within the runner's
39+
context.
3940
4041
This can be useful for interactive console (e.g. IPython),
4142
unittest runners, console tools, -- everywhere when async code

Lib/asyncio/selector_events.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -530,11 +530,12 @@ def _sock_recvfrom_into(self, fut, sock, buf, bufsize):
530530
async def sock_sendall(self, sock, data):
531531
"""Send data to the socket.
532532
533-
The socket must be connected to a remote socket. This method continues
534-
to send data from data until either all data has been sent or an
535-
error occurs. None is returned on success. On error, an exception is
536-
raised, and there is no way to determine how much data, if any, was
537-
successfully processed by the receiving end of the connection.
533+
The socket must be connected to a remote socket. This method
534+
continues to send data from data until either all data has been
535+
sent or an error occurs. None is returned on success. On error,
536+
an exception is raised, and there is no way to determine how much
537+
data, if any, was successfully processed by the receiving end of
538+
the connection.
538539
"""
539540
base_events._check_ssl_socket(sock)
540541
if self._debug and sock.gettimeout() != 0:
@@ -583,11 +584,12 @@ def _sock_sendall(self, fut, sock, view, pos):
583584
async def sock_sendto(self, sock, data, address):
584585
"""Send data to the socket.
585586
586-
The socket must be connected to a remote socket. This method continues
587-
to send data from data until either all data has been sent or an
588-
error occurs. None is returned on success. On error, an exception is
589-
raised, and there is no way to determine how much data, if any, was
590-
successfully processed by the receiving end of the connection.
587+
The socket must be connected to a remote socket. This method
588+
continues to send data from data until either all data has been
589+
sent or an error occurs. None is returned on success. On error,
590+
an exception is raised, and there is no way to determine how much
591+
data, if any, was successfully processed by the receiving end of
592+
the connection.
591593
"""
592594
base_events._check_ssl_socket(sock)
593595
if self._debug and sock.gettimeout() != 0:
@@ -698,10 +700,11 @@ def _sock_connect_cb(self, fut, sock, address):
698700
async def sock_accept(self, sock):
699701
"""Accept a connection.
700702
701-
The socket must be bound to an address and listening for connections.
702-
The return value is a pair (conn, address) where conn is a new socket
703-
object usable to send and receive data on the connection, and address
704-
is the address bound to the socket on the other end of the connection.
703+
The socket must be bound to an address and listening for
704+
connections. The return value is a pair (conn, address) where
705+
conn is a new socket object usable to send and receive data on the
706+
connection, and address is the address bound to the socket on the
707+
other end of the connection.
705708
"""
706709
base_events._check_ssl_socket(sock)
707710
if self._debug and sock.gettimeout() != 0:

Lib/asyncio/streams.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -541,17 +541,17 @@ async def _wait_for_data(self, func_name):
541541
self._waiter = None
542542

543543
async def readline(self):
544-
"""Read chunk of data from the stream until newline (b'\n') is found.
544+
r"""Read chunk of data from the stream until newline (b'\n') is found.
545545
546-
On success, return chunk that ends with newline. If only partial
546+
On success, return chunk that ends with newline. If only partial
547547
line can be read due to EOF, return incomplete line without
548-
terminating newline. When EOF was reached while no bytes read, empty
549-
bytes object is returned.
548+
terminating newline. When EOF was reached while no bytes read,
549+
empty bytes object is returned.
550550
551-
If limit is reached, ValueError will be raised. In that case, if
551+
If limit is reached, ValueError will be raised. In that case, if
552552
newline was found, complete line including newline will be removed
553-
from internal buffer. Else, internal buffer will be cleared. Limit is
554-
compared against part of the line without newline.
553+
from internal buffer. Else, internal buffer will be cleared.
554+
Limit is compared against part of the line without newline.
555555
556556
If stream was paused, this function will automatically resume it if
557557
needed.

0 commit comments

Comments
 (0)