]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
*: More small pyupgrade cleanups
authorBen Darnell <ben@bendarnell.com>
Thu, 13 Jun 2024 18:52:19 +0000 (14:52 -0400)
committerBen Darnell <ben@bendarnell.com>
Thu, 13 Jun 2024 18:52:19 +0000 (14:52 -0400)
- Unpack list comprehension
- Redundant calls to str() on string literals
- Unnecessary args to super()

With the previous commits, this brings us up to
pyupgrade --py3-plus --keep-percent-format

tornado/auth.py
tornado/httpclient.py
tornado/httputil.py
tornado/ioloop.py
tornado/util.py

index 34bc8f032ae5f1314419bbdb35309080ccb6271e..73acf9e93e82f26d76c95170782cf68516d0b034 100644 (file)
@@ -375,9 +375,9 @@ class OAuthMixin:
         if not request_cookie:
             raise AuthError("Missing OAuth request token cookie")
         handler.clear_cookie("_oauth_request_token")
-        cookie_key, cookie_secret = [
+        cookie_key, cookie_secret = (
             base64.b64decode(escape.utf8(i)) for i in request_cookie.split("|")
-        ]
+        )
         if cookie_key != request_key:
             raise AuthError("Request token does not match cookie")
         token = dict(
index b26ed449ef67ca480673bbc66c3dd9d0fbad78e5..879c45f6269ae79f0213d96700dbc50171c5c56c 100644 (file)
@@ -203,7 +203,7 @@ class AsyncHTTPClient(Configurable):
             instance_cache = cls._async_clients()
         if instance_cache is not None and io_loop in instance_cache:
             return instance_cache[io_loop]
-        instance = super(AsyncHTTPClient, cls).__new__(cls, **kwargs)  # type: ignore
+        instance = super().__new__(cls, **kwargs)  # type: ignore
         # Make sure the instance knows which cache to remove itself from.
         # It can't simply call _async_clients() because we may be in
         # __new__(AsyncHTTPClient) but instance.__class__ may be
@@ -333,7 +333,7 @@ class AsyncHTTPClient(Configurable):
 
            AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")
         """
-        super(AsyncHTTPClient, cls).configure(impl, **kwargs)
+        super().configure(impl, **kwargs)
 
 
 class HTTPRequest:
index ecd53742c3ad2f07b38ce1abd800f6102f9de842..bffb7bd0096d39aad6f1f382a7ad4a4534e5a5fd 100644 (file)
@@ -1132,13 +1132,13 @@ def parse_cookie(cookie: str) -> Dict[str, str]:
     .. versionadded:: 4.4.2
     """
     cookiedict = {}
-    for chunk in cookie.split(str(";")):
-        if str("=") in chunk:
-            key, val = chunk.split(str("="), 1)
+    for chunk in cookie.split(";"):
+        if "=" in chunk:
+            key, val = chunk.split("=", 1)
         else:
             # Assume an empty name per
             # https://bugzilla.mozilla.org/show_bug.cgi?id=169091
-            key, val = str(""), chunk
+            key, val = "", chunk
         key, val = key.strip(), val.strip()
         if key or val:
             # unquote using Python's algorithm.
index 612aac3e8c6fb58692ec3b0ec2b233f81bbe806e..e6a1796841969993da45a2604dca3f4787b086a5 100644 (file)
@@ -178,7 +178,7 @@ class IOLoop(Configurable):
             impl = import_object(impl)
         if isinstance(impl, type) and not issubclass(impl, BaseAsyncIOLoop):
             raise RuntimeError("only AsyncIOLoop is allowed when asyncio is available")
-        super(IOLoop, cls).configure(impl, **kwargs)
+        super().configure(impl, **kwargs)
 
     @staticmethod
     def instance() -> "IOLoop":
index bf907b336bf98dc4c04e3e320a6a356e670ffb63..2e5eee792bd4dc7d95997a620df9f6b293a87e36 100644 (file)
@@ -252,7 +252,7 @@ class Configurable:
         if impl.configurable_base() is not base:
             # The impl class is itself configurable, so recurse.
             return impl(*args, **init_kwargs)
-        instance = super(Configurable, cls).__new__(impl)
+        instance = super().__new__(impl)
         # initialize vs __init__ chosen for compatibility with AsyncHTTPClient
         # singleton magic.  If we get rid of that we can switch to __init__
         # here too.