diff --git a/swift/common/manager.py b/swift/common/manager.py index eb1e93ae20..ca1bc3ca26 100644 --- a/swift/common/manager.py +++ b/swift/common/manager.py @@ -462,10 +462,10 @@ class Server(object): # maybe there's a config file(s) out there, but I couldn't find it! if not kwargs.get('quiet'): if number: - print(_('Unable to locate config number %s for %s' % ( - number, self.server))) + print(_('Unable to locate config number %s for %s') + % (number, self.server)) else: - print(_('Unable to locate config for %s' % (self.server))) + print(_('Unable to locate config for %s') % self.server) if kwargs.get('verbose') and not kwargs.get('quiet'): if found_conf_files: print(_('Found configs:')) diff --git a/swift/obj/auditor.py b/swift/obj/auditor.py index 1e218a2a1b..4875bb2520 100644 --- a/swift/obj/auditor.py +++ b/swift/obj/auditor.py @@ -331,7 +331,7 @@ class ObjectAuditor(Daemon): try: self.audit_loop(parent, zbo_fps, **kwargs) except (Exception, Timeout) as err: - self.logger.exception(_('ERROR auditing: %s' % err)) + self.logger.exception(_('ERROR auditing: %s'), err) self._sleep() def run_once(self, *args, **kwargs): @@ -352,4 +352,4 @@ class ObjectAuditor(Daemon): self.audit_loop(parent, zbo_fps, override_devices=override_devices, **kwargs) except (Exception, Timeout) as err: - self.logger.exception(_('ERROR auditing: %s' % err)) + self.logger.exception(_('ERROR auditing: %s'), err) diff --git a/test/unit/obj/test_auditor.py b/test/unit/obj/test_auditor.py index eb36edf500..2429879e5d 100644 --- a/test/unit/obj/test_auditor.py +++ b/test/unit/obj/test_auditor.py @@ -546,6 +546,8 @@ class TestAuditor(unittest.TestCase): class Bogus(Exception): pass + loop_error = Bogus('exception') + class ObjectAuditorMock(object): check_args = () check_kwargs = {} @@ -568,7 +570,7 @@ class TestAuditor(unittest.TestCase): def mock_audit_loop_error(self, parent, zbo_fps, override_devices=None, **kwargs): - raise Bogus('exception') + raise loop_error def mock_fork(self): self.fork_called += 1 @@ -602,11 +604,11 @@ class TestAuditor(unittest.TestCase): my_auditor._sleep = mocker.mock_sleep_stop my_auditor.run_once(zero_byte_fps=50) my_auditor.logger.exception.assert_called_once_with( - 'ERROR auditing: exception') + 'ERROR auditing: %s', loop_error) my_auditor.logger.exception.reset_mock() self.assertRaises(StopForever, my_auditor.run_forever) my_auditor.logger.exception.assert_called_once_with( - 'ERROR auditing: exception') + 'ERROR auditing: %s', loop_error) my_auditor.audit_loop = real_audit_loop self.assertRaises(StopForever, diff --git a/tox.ini b/tox.ini index 50236788c4..53d3bf78a8 100644 --- a/tox.ini +++ b/tox.ini @@ -68,8 +68,7 @@ commands = bandit -c bandit.yaml -r swift bin -n 5 -p gate # H404: multi line docstring should start without a leading new line # H405: multi line docstring summary not separated with an empty line # H501: Do not use self.__dict__ for string formatting -# H702: Formatting operation should be outside of localization method call # H703: Multiple positional placeholders -ignore = F402,F812,H101,H202,H233,H234,H301,H306,H401,H403,H404,H405,H501,H702,H703 +ignore = F402,F812,H101,H202,H233,H234,H301,H306,H401,H403,H404,H405,H501,H703 exclude = .venv,.tox,dist,doc,*egg show-source = True