diff --git a/src/App/Undo.py b/src/App/Undo.py index 9d9bf2521e..821cd9d53c 100644 --- a/src/App/Undo.py +++ b/src/App/Undo.py @@ -118,7 +118,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/OFS/ObjectManager.py b/src/OFS/ObjectManager.py index 7c475e5f23..c6c75110bc 100644 --- a/src/OFS/ObjectManager.py +++ b/src/OFS/ObjectManager.py @@ -783,9 +783,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/PageTemplates/tests/test_engine.py b/src/Products/PageTemplates/tests/test_engine.py index 6af0ce91c1..1f87848be5 100644 --- a/src/Products/PageTemplates/tests/test_engine.py +++ b/src/Products/PageTemplates/tests/test_engine.py @@ -68,7 +68,7 @@ def test_zopepagetemplate(self): self.assertIn( 'Hello world', template( - greeting='Hello world') + greeting='Hello world') ) # test commit diff --git a/src/Products/SiteAccess/VirtualHostMonster.py b/src/Products/SiteAccess/VirtualHostMonster.py index e57d2e8ba2..2d9e6134aa 100644 --- a/src/Products/SiteAccess/VirtualHostMonster.py +++ b/src/Products/SiteAccess/VirtualHostMonster.py @@ -60,7 +60,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/testHTTPResponse.py b/src/ZPublisher/tests/testHTTPResponse.py index 9a4b5b19e4..aad39f3b09 100644 --- a/src/ZPublisher/tests/testHTTPResponse.py +++ b/src/ZPublisher/tests/testHTTPResponse.py @@ -929,7 +929,7 @@ def test_badRequestError_valid_parameter_name(self): self.assertEqual(response.status, 400) self.assertIn( "The parameter, some_parameter, " - "was omitted from the request.", + "was omitted from the request.", str(raised) ) else: @@ -943,7 +943,7 @@ def test_badRequestError_invalid_parameter_name(self): self.assertEqual(response.status, 400) self.assertIn( "Sorry, an internal error occurred in this " - "resource.", + "resource.", str(raised) ) else: @@ -958,7 +958,7 @@ def test__unauthorized_no_realm(self): def test__unauthorized_w_default_realm(self): response = self._makeOne() response._unauthorized() - self.assertIn('WWW-Authenticate', response.headers) # literal + self.assertIn('WWW-Authenticate', response.headers) # literal self.assertEqual(response.headers['WWW-Authenticate'], 'basic realm="Zope", charset="UTF-8"') @@ -966,7 +966,7 @@ def test__unauthorized_w_realm(self): response = self._makeOne() response.realm = 'Folly' response._unauthorized() - self.assertIn('WWW-Authenticate', response.headers) # literal + self.assertIn('WWW-Authenticate', response.headers) # literal self.assertEqual(response.headers['WWW-Authenticate'], 'basic realm="Folly", charset="UTF-8"') @@ -978,7 +978,7 @@ def test_unauthorized_no_debug_mode(self): self.assertEqual(response.status, 200) # publisher sets 401 later self.assertIn( "You are not authorized " - "to access this resource.", + "to access this resource.", str(raised) ) else: diff --git a/src/ZPublisher/tests/test_xmlrpc.py b/src/ZPublisher/tests/test_xmlrpc.py index 025badfc43..f742354f4d 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 62b926f628..b571ac7741 100644 --- a/src/ZTUtils/Tree.py +++ b/src/ZTUtils/Tree.py @@ -223,7 +223,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/ZTUtils/tests/testTree.py b/src/ZTUtils/tests/testTree.py index 8df4c07646..603bde28d3 100644 --- a/src/ZTUtils/tests/testTree.py +++ b/src/ZTUtils/tests/testTree.py @@ -451,6 +451,6 @@ def testDecodeDecompressedSizeLimit(self): from ZTUtils.Tree import b2a big = b2a(zlib.compress(b'x' * (1024 * 1100))) - self.assertLess(len(big), 8192) # Must be under the input size limit + self.assertLess(len(big), 8192) # Must be under the input size limit with self.assertRaises(ValueError): Tree.decodeExpansion(b':' + big) diff --git a/src/Zope2/utilities/mkwsgiinstance.py b/src/Zope2/utilities/mkwsgiinstance.py index 107d48072d..f87d4ed854 100644 --- a/src/Zope2/utilities/mkwsgiinstance.py +++ b/src/Zope2/utilities/mkwsgiinstance.py @@ -224,7 +224,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: