From 7b9921a4fae06e461204415786775e7b7014e5a5 Mon Sep 17 00:00:00 2001 From: Jens Vagelpohl Date: Tue, 28 May 2024 08:46:32 +0200 Subject: [PATCH] - run pyupgrade --- src/App/Undo.py | 2 +- src/App/ZODBConnectionDebugger.py | 2 +- src/OFS/ObjectManager.py | 4 ++-- src/Products/SiteAccess/VirtualHostMonster.py | 2 +- src/ZPublisher/tests/test_xmlrpc.py | 2 +- src/ZTUtils/Tree.py | 2 +- src/Zope2/utilities/mkwsgiinstance.py | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/App/Undo.py b/src/App/Undo.py index 374c22ae77..2d9316b33a 100644 --- a/src/App/Undo.py +++ b/src/App/Undo.py @@ -122,7 +122,7 @@ def manage_undo_transactions(self, transaction_info=(), REQUEST=None): raise ts.abort() - error = '{}: {}'.format(exc.__class__.__name__, str(exc)) + error = f'{exc.__class__.__name__}: {str(exc)}' return self.manage_UndoForm(self, REQUEST, manage_tabs_message=error, manage_tabs_type='danger') diff --git a/src/App/ZODBConnectionDebugger.py b/src/App/ZODBConnectionDebugger.py index 9167d42c32..3c97a26d97 100644 --- a/src/App/ZODBConnectionDebugger.py +++ b/src/App/ZODBConnectionDebugger.py @@ -67,7 +67,7 @@ def get_info(connection): # output UTC time with the standard Z time zone indicator open_since = "{}".format( time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(opened))) - open_for = "{:.2f}s".format(now - opened) + open_for = f"{now - opened:.2f}s" else: open_since = '(closed)' open_for = '' diff --git a/src/OFS/ObjectManager.py b/src/OFS/ObjectManager.py index 674a5cdeed..02542280b1 100644 --- a/src/OFS/ObjectManager.py +++ b/src/OFS/ObjectManager.py @@ -788,9 +788,9 @@ def compute_size(self, ob): if ob_size < 1024: return '1 KiB' elif ob_size > 1048576: - return "{:0.02f} MiB".format(ob_size / 1048576.0) + return f"{ob_size / 1048576.0:0.02f} MiB" else: - return "{:0.0f} KiB".format(ob_size / 1024.0) + return f"{ob_size / 1024.0:0.0f} KiB" @security.protected(access_contents_information) def last_modified(self, ob): diff --git a/src/Products/SiteAccess/VirtualHostMonster.py b/src/Products/SiteAccess/VirtualHostMonster.py index 4732a98f42..745f396896 100644 --- a/src/Products/SiteAccess/VirtualHostMonster.py +++ b/src/Products/SiteAccess/VirtualHostMonster.py @@ -64,7 +64,7 @@ def set_map(self, map_text, RESPONSE=None): # Drop the protocol, if any line = line.split('://')[-1] try: - host, path = [x.strip() for x in line.split('/', 1)] + host, path = (x.strip() for x in line.split('/', 1)) except Exception: raise ValueError( 'Line needs a slash between host and path: %s' % line) diff --git a/src/ZPublisher/tests/test_xmlrpc.py b/src/ZPublisher/tests/test_xmlrpc.py index 5a73ef232e..ab61ac8948 100644 --- a/src/ZPublisher/tests/test_xmlrpc.py +++ b/src/ZPublisher/tests/test_xmlrpc.py @@ -42,7 +42,7 @@ def test_setBody(self): response.setBody(body) body_str = faux._body - self.assertEqual(type(body_str), type('')) + self.assertEqual(type(body_str), str) as_set, method = xmlrpc.client.loads(body_str) as_set = as_set[0] diff --git a/src/ZTUtils/Tree.py b/src/ZTUtils/Tree.py index b9895aa1dc..c6d760710c 100644 --- a/src/ZTUtils/Tree.py +++ b/src/ZTUtils/Tree.py @@ -225,7 +225,7 @@ def tree(self, root, expanded=None, subtree=0): return node -_SIMPLE_TYPES = {type(''), type(b''), type(0), type(0.0), type(None)} +_SIMPLE_TYPES = {str, bytes, int, float, type(None)} def simple_type(ob): diff --git a/src/Zope2/utilities/mkwsgiinstance.py b/src/Zope2/utilities/mkwsgiinstance.py index faf76b3962..765a281460 100644 --- a/src/Zope2/utilities/mkwsgiinstance.py +++ b/src/Zope2/utilities/mkwsgiinstance.py @@ -227,7 +227,7 @@ def get_zope2path(python): try: output = subprocess.check_output( [python, '-c', 'import Zope2; print(Zope2.__file__)'], - universal_newlines=True, # makes Python 3 return text, not bytes + text=True, # makes Python 3 return text, not bytes stderr=subprocess.PIPE) zope2file = output.strip() except subprocess.CalledProcessError: