Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 15cc678

Browse files
committed
asyncio: Truncate to 80 columns
1 parent 8d9c145 commit 15cc678

12 files changed

Lines changed: 60 additions & 33 deletions

Lib/asyncio/base_events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ def _make_socket_transport(self, sock, protocol, waiter=None, *,
201201
"""Create socket transport."""
202202
raise NotImplementedError
203203

204-
def _make_ssl_transport(self, rawsock, protocol, sslcontext, waiter=None, *,
205-
server_side=False, server_hostname=None,
204+
def _make_ssl_transport(self, rawsock, protocol, sslcontext, waiter=None,
205+
*, server_side=False, server_hostname=None,
206206
extra=None, server=None):
207207
"""Create SSL transport."""
208208
raise NotImplementedError

Lib/asyncio/coroutines.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,18 @@ def _format_coroutine(coro):
182182
and not inspect.isgeneratorfunction(coro.func)):
183183
filename, lineno = events._get_function_source(coro.func)
184184
if coro.gi_frame is None:
185-
coro_repr = '%s() done, defined at %s:%s' % (coro_name, filename, lineno)
185+
coro_repr = ('%s() done, defined at %s:%s'
186+
% (coro_name, filename, lineno))
186187
else:
187-
coro_repr = '%s() running, defined at %s:%s' % (coro_name, filename, lineno)
188+
coro_repr = ('%s() running, defined at %s:%s'
189+
% (coro_name, filename, lineno))
188190
elif coro.gi_frame is not None:
189191
lineno = coro.gi_frame.f_lineno
190-
coro_repr = '%s() running at %s:%s' % (coro_name, filename, lineno)
192+
coro_repr = ('%s() running at %s:%s'
193+
% (coro_name, filename, lineno))
191194
else:
192195
lineno = coro.gi_code.co_firstlineno
193-
coro_repr = '%s() done, defined at %s:%s' % (coro_name, filename, lineno)
196+
coro_repr = ('%s() done, defined at %s:%s'
197+
% (coro_name, filename, lineno))
194198

195199
return coro_repr

Lib/asyncio/selector_events.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ def _make_socket_transport(self, sock, protocol, waiter=None, *,
5555
return _SelectorSocketTransport(self, sock, protocol, waiter,
5656
extra, server)
5757

58-
def _make_ssl_transport(self, rawsock, protocol, sslcontext, waiter=None, *,
59-
server_side=False, server_hostname=None,
58+
def _make_ssl_transport(self, rawsock, protocol, sslcontext, waiter=None,
59+
*, server_side=False, server_hostname=None,
6060
extra=None, server=None):
6161
return _SelectorSslTransport(
6262
self, rawsock, protocol, sslcontext, waiter,
@@ -484,7 +484,8 @@ def __repr__(self):
484484
info.append('read=idle')
485485

486486
polling = _test_selector_event(self._loop._selector,
487-
self._sock_fd, selectors.EVENT_WRITE)
487+
self._sock_fd,
488+
selectors.EVENT_WRITE)
488489
if polling:
489490
state = 'polling'
490491
else:

Lib/asyncio/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def all_tasks(cls, loop=None):
6868
return {t for t in cls._all_tasks if t._loop is loop}
6969

7070
def __init__(self, coro, *, loop=None):
71-
assert coroutines.iscoroutine(coro), repr(coro) # Not a coroutine function!
71+
assert coroutines.iscoroutine(coro), repr(coro)
7272
super().__init__(loop=loop)
7373
if self._source_traceback:
7474
del self._source_traceback[-1]

Lib/asyncio/unix_events.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ def add_signal_handler(self, sig, callback, *args):
6969
"""
7070
if (coroutines.iscoroutine(callback)
7171
or coroutines.iscoroutinefunction(callback)):
72-
raise TypeError("coroutines cannot be used with add_signal_handler()")
72+
raise TypeError("coroutines cannot be used "
73+
"with add_signal_handler()")
7374
self._check_signal(sig)
7475
self._check_closed()
7576
try:

Lib/asyncio/windows_events.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,8 @@ def finish_connect_pipe(err, handle, ov):
424424
else:
425425
return windows_utils.PipeHandle(handle)
426426

427-
return self._register(ov, None, finish_connect_pipe, wait_for_post=True)
427+
return self._register(ov, None, finish_connect_pipe,
428+
wait_for_post=True)
428429

429430
def wait_for_handle(self, handle, timeout=None):
430431
"""Wait for a handle.

Lib/asyncio/windows_utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@
3636
def socketpair(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0):
3737
"""A socket pair usable as a self-pipe, for Windows.
3838
39-
Origin: https://gist.github.com/4325783, by Geert Jansen. Public domain.
39+
Origin: https://gist.github.com/4325783, by Geert Jansen.
40+
Public domain.
4041
"""
4142
if family == socket.AF_INET:
4243
host = '127.0.0.1'
4344
elif family == socket.AF_INET6:
4445
host = '::1'
4546
else:
46-
raise ValueError("Only AF_INET and AF_INET6 socket address families "
47-
"are supported")
47+
raise ValueError("Only AF_INET and AF_INET6 socket address "
48+
"families are supported")
4849
if type != socket.SOCK_STREAM:
4950
raise ValueError("Only SOCK_STREAM socket type is supported")
5051
if proto != 0:

Lib/test/test_asyncio/test_base_events.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ def test_set_debug(self):
285285
@mock.patch('asyncio.base_events.logger')
286286
def test__run_once_logging(self, m_logger):
287287
def slow_select(timeout):
288-
# Sleep a bit longer than a second to avoid timer resolution issues.
288+
# Sleep a bit longer than a second to avoid timer resolution
289+
# issues.
289290
time.sleep(1.1)
290291
return []
291292

@@ -1217,14 +1218,16 @@ def stop_loop_coro(loop):
12171218
self.loop.run_forever()
12181219
fmt, *args = m_logger.warning.call_args[0]
12191220
self.assertRegex(fmt % tuple(args),
1220-
"^Executing <Handle.*stop_loop_cb.*> took .* seconds$")
1221+
"^Executing <Handle.*stop_loop_cb.*> "
1222+
"took .* seconds$")
12211223

12221224
# slow task
12231225
asyncio.async(stop_loop_coro(self.loop), loop=self.loop)
12241226
self.loop.run_forever()
12251227
fmt, *args = m_logger.warning.call_args[0]
12261228
self.assertRegex(fmt % tuple(args),
1227-
"^Executing <Task.*stop_loop_coro.*> took .* seconds$")
1229+
"^Executing <Task.*stop_loop_coro.*> "
1230+
"took .* seconds$")
12281231

12291232

12301233
if __name__ == '__main__':

Lib/test/test_asyncio/test_futures.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ def test_future_repr(self):
133133
exc = RuntimeError()
134134
f_exception = asyncio.Future(loop=self.loop)
135135
f_exception.set_exception(exc)
136-
self.assertEqual(repr(f_exception), '<Future finished exception=RuntimeError()>')
136+
self.assertEqual(repr(f_exception),
137+
'<Future finished exception=RuntimeError()>')
137138
self.assertIs(f_exception.exception(), exc)
138139

139140
def func_repr(func):
@@ -332,16 +333,21 @@ def memory_error():
332333
if debug:
333334
frame = source_traceback[-1]
334335
regex = (r'^Future exception was never retrieved\n'
335-
r'future: <Future finished exception=MemoryError\(\) created at {filename}:{lineno}>\n'
336-
r'source_traceback: Object created at \(most recent call last\):\n'
336+
r'future: <Future finished exception=MemoryError\(\) '
337+
r'created at {filename}:{lineno}>\n'
338+
r'source_traceback: Object '
339+
r'created at \(most recent call last\):\n'
337340
r' File'
338341
r'.*\n'
339-
r' File "{filename}", line {lineno}, in check_future_exception_never_retrieved\n'
342+
r' File "{filename}", line {lineno}, '
343+
r'in check_future_exception_never_retrieved\n'
340344
r' future = asyncio\.Future\(loop=self\.loop\)$'
341-
).format(filename=re.escape(frame[0]), lineno=frame[1])
345+
).format(filename=re.escape(frame[0]),
346+
lineno=frame[1])
342347
else:
343348
regex = (r'^Future exception was never retrieved\n'
344-
r'future: <Future finished exception=MemoryError\(\)>$'
349+
r'future: '
350+
r'<Future finished exception=MemoryError\(\)>$'
345351
)
346352
exc_info = (type(exc), exc, exc.__traceback__)
347353
m_log.error.assert_called_once_with(mock.ANY, exc_info=exc_info)
@@ -352,12 +358,14 @@ def memory_error():
352358
r'Future/Task created at \(most recent call last\):\n'
353359
r' File'
354360
r'.*\n'
355-
r' File "{filename}", line {lineno}, in check_future_exception_never_retrieved\n'
361+
r' File "{filename}", line {lineno}, '
362+
r'in check_future_exception_never_retrieved\n'
356363
r' future = asyncio\.Future\(loop=self\.loop\)\n'
357364
r'Traceback \(most recent call last\):\n'
358365
r'.*\n'
359366
r'MemoryError$'
360-
).format(filename=re.escape(frame[0]), lineno=frame[1])
367+
).format(filename=re.escape(frame[0]),
368+
lineno=frame[1])
361369
else:
362370
regex = (r'^Future/Task exception was never retrieved\n'
363371
r'Traceback \(most recent call last\):\n'

Lib/test/test_asyncio/test_streams.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,10 @@ def test_read_all_from_pipe_reader(self):
613613
watcher.attach_loop(self.loop)
614614
try:
615615
asyncio.set_child_watcher(watcher)
616-
proc = self.loop.run_until_complete(
617-
asyncio.create_subprocess_exec(*args, pass_fds={wfd}, loop=self.loop))
616+
create = asyncio.create_subprocess_exec(*args,
617+
pass_fds={wfd},
618+
loop=self.loop)
619+
proc = self.loop.run_until_complete(create)
618620
self.loop.run_until_complete(proc.wait())
619621
finally:
620622
asyncio.set_child_watcher(None)

0 commit comments

Comments
 (0)