Skip to content

Commit

Permalink
[pre-commit.ci lite] apply automatic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci-lite[bot] authored Sep 21, 2023
1 parent dcaf00b commit bfe6aa9
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/App/Undo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions src/OFS/ObjectManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/Products/PageTemplates/tests/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_zopepagetemplate(self):
self.assertIn(
'Hello world',
template(
greeting='Hello world')
greeting='Hello world')
)

# test commit
Expand Down
2 changes: 1 addition & 1 deletion src/Products/SiteAccess/VirtualHostMonster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions src/ZPublisher/tests/testHTTPResponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ def test_badRequestError_valid_parameter_name(self):
self.assertEqual(response.status, 400)
self.assertIn(
"The parameter, <em>some_parameter</em>, "
"was omitted from the request.",
"was omitted from the request.",
str(raised)
)
else:
Expand All @@ -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:
Expand All @@ -958,15 +958,15 @@ 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"')

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"')

Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/ZPublisher/tests/test_xmlrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/ZTUtils/Tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/ZTUtils/tests/testTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion src/Zope2/utilities/mkwsgiinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit bfe6aa9

Please sign in to comment.