]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
*: Update black 3385/head
authorBen Darnell <ben@bendarnell.com>
Tue, 4 Jun 2024 18:19:52 +0000 (14:19 -0400)
committerBen Darnell <ben@bendarnell.com>
Tue, 4 Jun 2024 18:19:52 +0000 (14:19 -0400)
Closes #3367

.flake8
demos/blog/blog.py
demos/google_auth/main.py
requirements.txt
tornado/concurrent.py
tornado/gen.py
tornado/simple_httpclient.py
tornado/test/__main__.py
tornado/test/escape_test.py
tornado/test/ioloop_test.py
tornado/websocket.py

diff --git a/.flake8 b/.flake8
index 18c72168cb57823d63cadd0fe3fdb93c7a7e4c18..3a7da2c65223f6287364cac1c99f4a63f30f9f25 100644 (file)
--- a/.flake8
+++ b/.flake8
@@ -13,5 +13,7 @@ ignore =
     # flake8 and black disagree about
     # W503 line break before binary operator
     # E203 whitespace before ':'
-    W503,E203
+    # E701/E704 multiple statements on one line
+    # https://black.readthedocs.io/en/latest/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings
+    W503,E203,E701,E704
 doctests = true
index bd0c5b3f18b0a180a1760f0151276955c3bb6bb4..e6e23f85b4aab0be8cb1b2163595dff3cd62e340 100755 (executable)
@@ -40,13 +40,13 @@ class NoResultError(Exception):
 
 async def maybe_create_tables(db):
     try:
-        with (await db.cursor()) as cur:
+        with await db.cursor() as cur:
             await cur.execute("SELECT COUNT(*) FROM entries LIMIT 1")
             await cur.fetchone()
     except psycopg2.ProgrammingError:
         with open("schema.sql") as f:
             schema = f.read()
-        with (await db.cursor()) as cur:
+        with await db.cursor() as cur:
             await cur.execute(schema)
 
 
@@ -89,7 +89,7 @@ class BaseHandler(tornado.web.RequestHandler):
 
         Must be called with ``await self.execute(...)``
         """
-        with (await self.application.db.cursor()) as cur:
+        with await self.application.db.cursor() as cur:
             await cur.execute(stmt, args)
 
     async def query(self, stmt, *args):
@@ -103,7 +103,7 @@ class BaseHandler(tornado.web.RequestHandler):
 
             for row in await self.query(...)
         """
-        with (await self.application.db.cursor()) as cur:
+        with await self.application.db.cursor() as cur:
             await cur.execute(stmt, args)
             return [self.row_to_obj(row, cur) for row in await cur.fetchall()]
 
index 06dd3b5cdb5e045b35a3e5096b35760a37d2ef45..40cdd7a4fdee6974ef0169de3c1ba0de836a18e8 100644 (file)
@@ -10,6 +10,7 @@ Recommended usage:
 - Run this file with `python main.py --config_file=main.cfg`
 - Visit "http://localhost:8888" in your browser.
 """
+
 import asyncio
 import json
 import tornado
index 5245bbc2494c3662c27122f9454638a047541789..025f3adbfccb9ba16bc23506f44ebf3b09c751d7 100644 (file)
@@ -8,7 +8,7 @@ alabaster==0.7.13
     # via sphinx
 babel==2.11.0
     # via sphinx
-black==22.12.0
+black==24.4.2
     # via -r requirements.in
 build==0.10.0
     # via pip-tools
@@ -56,6 +56,7 @@ mypy-extensions==0.4.3
     #   mypy
 packaging==23.1
     # via
+    #   black
     #   build
     #   pyproject-api
     #   sphinx
index 86bbd703c1da1ab7254037765d7486fbdccbdb1a..5047c5389fd6aa16dac74c66eba625825de4f7d9 100644 (file)
@@ -118,6 +118,7 @@ def run_on_executor(*args: Any, **kwargs: Any) -> Callable:
 
        The ``callback`` argument was removed.
     """
+
     # Fully type-checking decorators is tricky, and this one is
     # discouraged anyway so it doesn't have all the generic magic.
     def run_on_executor_decorator(fn: Callable) -> Callable[..., Future]:
index dab4fd09db6cf85b9353626e5568d0ea17458042..0e3c7a6fc2a06e3221f34ed54e8a0b26eea38781 100644 (file)
@@ -66,6 +66,7 @@ function to extend this mechanism.
    via ``singledispatch``.
 
 """
+
 import asyncio
 import builtins
 import collections
@@ -165,13 +166,11 @@ def _fake_ctx_run(f: Callable[..., _T], *args: Any, **kw: Any) -> _T:
 @overload
 def coroutine(
     func: Callable[..., "Generator[Any, Any, _T]"]
-) -> Callable[..., "Future[_T]"]:
-    ...
+) -> Callable[..., "Future[_T]"]: ...
 
 
 @overload
-def coroutine(func: Callable[..., _T]) -> Callable[..., "Future[_T]"]:
-    ...
+def coroutine(func: Callable[..., _T]) -> Callable[..., "Future[_T]"]: ...
 
 
 def coroutine(
index 2460863fc10f6187071f119b8396478fef744f9a..5b2d4dcd98008c1b0ace732744a4442734af7455 100644 (file)
@@ -429,9 +429,9 @@ class _HTTPConnection(httputil.HTTPMessageDelegate):
                 self.request.method == "POST"
                 and "Content-Type" not in self.request.headers
             ):
-                self.request.headers[
-                    "Content-Type"
-                ] = "application/x-www-form-urlencoded"
+                self.request.headers["Content-Type"] = (
+                    "application/x-www-form-urlencoded"
+                )
             if self.request.decompress_response:
                 self.request.headers["Accept-Encoding"] = "gzip"
             req_path = (self.parsed.path or "/") + (
index 430c895fa249c6a754853e3bbe10628f8d704557..890bd505b4534e0960cf3089bdc0a7b859bb2347 100644 (file)
@@ -2,6 +2,7 @@
 
 This only works in python 2.7+.
 """
+
 from tornado.test.runtests import all, main
 
 # tornado.testing.main autodiscovery relies on 'all' being present in
index 6bd2ae79e444760d46a94caf7b0619f253bc9e90..3115a19409fe61dd3523d0e7b134cf41512eaff6 100644 (file)
@@ -194,9 +194,11 @@ linkify_tests = [
     (
         "www.external-link.com and www.internal-link.com/blogs extra",
         {
-            "extra_params": lambda href: 'class="internal"'
-            if href.startswith("http://www.internal-link.com")
-            else 'rel="nofollow" class="external"'
+            "extra_params": lambda href: (
+                'class="internal"'
+                if href.startswith("http://www.internal-link.com")
+                else 'rel="nofollow" class="external"'
+            )
         },
         '<a href="http://www.external-link.com" rel="nofollow" class="external">www.external-link.com</a>'  # noqa: E501
         ' and <a href="http://www.internal-link.com/blogs" class="internal">www.internal-link.com/blogs</a> extra',  # noqa: E501
index 9485afeaeb005e90a31cb9d2578249cf44db58df..d07438aa6321ab9223f65667b5df522d1cfbfaa7 100644 (file)
@@ -261,6 +261,7 @@ class TestIOLoop(AsyncTestCase):
         the object should be closed (by IOLoop.close(all_fds=True),
         not just the fd.
         """
+
         # Use a socket since they are supported by IOLoop on all platforms.
         # Unfortunately, sockets don't support the .closed attribute for
         # inspecting their close status, so we must use a wrapper.
index fbfd70088772ed89b5b7f2a582e45a36d8ff0c6e..8f0e0aefe89c7699450014e6d68490a0b05defc4 100644 (file)
@@ -1392,9 +1392,9 @@ class WebSocketClientConnection(simple_httpclient._HTTPConnection):
             # from the server).
             # TODO: set server parameters for deflate extension
             # if requested in self.compression_options.
-            request.headers[
-                "Sec-WebSocket-Extensions"
-            ] = "permessage-deflate; client_max_window_bits"
+            request.headers["Sec-WebSocket-Extensions"] = (
+                "permessage-deflate; client_max_window_bits"
+            )
 
         # Websocket connection is currently unable to follow redirects
         request.follow_redirects = False