From: Ben Darnell Date: Thu, 13 Jun 2024 18:52:19 +0000 (-0400) Subject: *: More small pyupgrade cleanups X-Git-Tag: v6.5.0b1~47^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39346ce1853cf12934c7a002f2aa042b4f96094b;p=thirdparty%2Ftornado.git *: More small pyupgrade cleanups - 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 --- diff --git a/tornado/auth.py b/tornado/auth.py index 34bc8f03..73acf9e9 100644 --- a/tornado/auth.py +++ b/tornado/auth.py @@ -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( diff --git a/tornado/httpclient.py b/tornado/httpclient.py index b26ed449..879c45f6 100644 --- a/tornado/httpclient.py +++ b/tornado/httpclient.py @@ -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: diff --git a/tornado/httputil.py b/tornado/httputil.py index ecd53742..bffb7bd0 100644 --- a/tornado/httputil.py +++ b/tornado/httputil.py @@ -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. diff --git a/tornado/ioloop.py b/tornado/ioloop.py index 612aac3e..e6a17968 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -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": diff --git a/tornado/util.py b/tornado/util.py index bf907b33..2e5eee79 100644 --- a/tornado/util.py +++ b/tornado/util.py @@ -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.