Skip to content

Commit 291d1b6

Browse files
committed
*: Update black
Closes #3367
1 parent b109915 commit 291d1b6

File tree

11 files changed

+27
-19
lines changed

11 files changed

+27
-19
lines changed

.flake8

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@ ignore =
1313
# flake8 and black disagree about
1414
# W503 line break before binary operator
1515
# E203 whitespace before ':'
16-
W503,E203
16+
# E701/E704 multiple statements on one line
17+
# https://black.readthedocs.io/en/latest/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings
18+
W503,E203,E701,E704
1719
doctests = true

demos/blog/blog.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ class NoResultError(Exception):
4040

4141
async def maybe_create_tables(db):
4242
try:
43-
with (await db.cursor()) as cur:
43+
with await db.cursor() as cur:
4444
await cur.execute("SELECT COUNT(*) FROM entries LIMIT 1")
4545
await cur.fetchone()
4646
except psycopg2.ProgrammingError:
4747
with open("schema.sql") as f:
4848
schema = f.read()
49-
with (await db.cursor()) as cur:
49+
with await db.cursor() as cur:
5050
await cur.execute(schema)
5151

5252

@@ -89,7 +89,7 @@ async def execute(self, stmt, *args):
8989
9090
Must be called with ``await self.execute(...)``
9191
"""
92-
with (await self.application.db.cursor()) as cur:
92+
with await self.application.db.cursor() as cur:
9393
await cur.execute(stmt, args)
9494

9595
async def query(self, stmt, *args):
@@ -103,7 +103,7 @@ async def query(self, stmt, *args):
103103
104104
for row in await self.query(...)
105105
"""
106-
with (await self.application.db.cursor()) as cur:
106+
with await self.application.db.cursor() as cur:
107107
await cur.execute(stmt, args)
108108
return [self.row_to_obj(row, cur) for row in await cur.fetchall()]
109109

demos/google_auth/main.py

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Run this file with `python main.py --config_file=main.cfg`
1111
- Visit "http://localhost:8888" in your browser.
1212
"""
13+
1314
import asyncio
1415
import json
1516
import tornado

requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ alabaster==0.7.13
88
# via sphinx
99
babel==2.11.0
1010
# via sphinx
11-
black==22.12.0
11+
black==24.4.2
1212
# via -r requirements.in
1313
build==0.10.0
1414
# via pip-tools
@@ -56,6 +56,7 @@ mypy-extensions==0.4.3
5656
# mypy
5757
packaging==23.1
5858
# via
59+
# black
5960
# build
6061
# pyproject-api
6162
# sphinx

tornado/concurrent.py

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def foo(self):
118118
119119
The ``callback`` argument was removed.
120120
"""
121+
121122
# Fully type-checking decorators is tricky, and this one is
122123
# discouraged anyway so it doesn't have all the generic magic.
123124
def run_on_executor_decorator(fn: Callable) -> Callable[..., Future]:

tornado/gen.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def get(self):
6666
via ``singledispatch``.
6767
6868
"""
69+
6970
import asyncio
7071
import builtins
7172
import collections
@@ -165,13 +166,11 @@ def _fake_ctx_run(f: Callable[..., _T], *args: Any, **kw: Any) -> _T:
165166
@overload
166167
def coroutine(
167168
func: Callable[..., "Generator[Any, Any, _T]"]
168-
) -> Callable[..., "Future[_T]"]:
169-
...
169+
) -> Callable[..., "Future[_T]"]: ...
170170

171171

172172
@overload
173-
def coroutine(func: Callable[..., _T]) -> Callable[..., "Future[_T]"]:
174-
...
173+
def coroutine(func: Callable[..., _T]) -> Callable[..., "Future[_T]"]: ...
175174

176175

177176
def coroutine(

tornado/simple_httpclient.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,9 @@ async def run(self) -> None:
429429
self.request.method == "POST"
430430
and "Content-Type" not in self.request.headers
431431
):
432-
self.request.headers[
433-
"Content-Type"
434-
] = "application/x-www-form-urlencoded"
432+
self.request.headers["Content-Type"] = (
433+
"application/x-www-form-urlencoded"
434+
)
435435
if self.request.decompress_response:
436436
self.request.headers["Accept-Encoding"] = "gzip"
437437
req_path = (self.parsed.path or "/") + (

tornado/test/__main__.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
This only works in python 2.7+.
44
"""
5+
56
from tornado.test.runtests import all, main
67

78
# tornado.testing.main autodiscovery relies on 'all' being present in

tornado/test/escape_test.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,11 @@
194194
(
195195
"www.external-link.com and www.internal-link.com/blogs extra",
196196
{
197-
"extra_params": lambda href: 'class="internal"'
198-
if href.startswith("http://www.internal-link.com")
199-
else 'rel="nofollow" class="external"'
197+
"extra_params": lambda href: (
198+
'class="internal"'
199+
if href.startswith("http://www.internal-link.com")
200+
else 'rel="nofollow" class="external"'
201+
)
200202
},
201203
'<a href="http://www.external-link.com" rel="nofollow" class="external">www.external-link.com</a>' # noqa: E501
202204
' and <a href="http://www.internal-link.com/blogs" class="internal">www.internal-link.com/blogs</a> extra', # noqa: E501

tornado/test/ioloop_test.py

+1
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ def test_close_file_object(self):
261261
the object should be closed (by IOLoop.close(all_fds=True),
262262
not just the fd.
263263
"""
264+
264265
# Use a socket since they are supported by IOLoop on all platforms.
265266
# Unfortunately, sockets don't support the .closed attribute for
266267
# inspecting their close status, so we must use a wrapper.

tornado/websocket.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1392,9 +1392,9 @@ def __init__(
13921392
# from the server).
13931393
# TODO: set server parameters for deflate extension
13941394
# if requested in self.compression_options.
1395-
request.headers[
1396-
"Sec-WebSocket-Extensions"
1397-
] = "permessage-deflate; client_max_window_bits"
1395+
request.headers["Sec-WebSocket-Extensions"] = (
1396+
"permessage-deflate; client_max_window_bits"
1397+
)
13981398

13991399
# Websocket connection is currently unable to follow redirects
14001400
request.follow_redirects = False

0 commit comments

Comments
 (0)