diff --git a/backup/drivers/xtrabackup.py b/backup/drivers/xtrabackup.py index f175857227..9a0529e5a7 100644 --- a/backup/drivers/xtrabackup.py +++ b/backup/drivers/xtrabackup.py @@ -52,9 +52,9 @@ class XtraBackup(mysql_base.MySQLBaseRunner): @property def cmd(self): - cmd = (f'xtrabackup --backup --stream=xbstream --parallel=2 ' - f'--datadir=%(datadir)s --user=%(user)s ' - f'--password=%(password)s --host=%(host)s' + cmd = ('xtrabackup --backup --stream=xbstream --parallel=2 ' + '--datadir=%(datadir)s --user=%(user)s ' + '--password=%(password)s --host=%(host)s' % { 'datadir': self.datadir, 'user': CONF.db_user, @@ -91,9 +91,9 @@ class XtraBackup(mysql_base.MySQLBaseRunner): class XtraBackupIncremental(XtraBackup): """XtraBackup incremental backup.""" prepare_log = '/tmp/prepare.log' - incremental_prep = (f'xtrabackup --prepare --apply-log-only' - f' --target-dir=%(restore_location)s' - f' %(incremental_args)s') + incremental_prep = ('xtrabackup --prepare --apply-log-only' + ' --target-dir=%(restore_location)s' + ' %(incremental_args)s') def __init__(self, *args, **kwargs): if not kwargs.get('lsn'): diff --git a/backup/tests/unittests/drivers/test_postgres.py b/backup/tests/unittests/drivers/test_postgres.py index bcee9b2f2a..d76db7410a 100644 --- a/backup/tests/unittests/drivers/test_postgres.py +++ b/backup/tests/unittests/drivers/test_postgres.py @@ -312,7 +312,7 @@ class TestPgBasebackupIncremental(unittest.TestCase): def test_incremental_restore_cmd(self): # prepare the test runner = self.runner_cls(**self.params) - cmd = f'tar xzf - -C /var/lib/postgresql/data/pgdata' + cmd = 'tar xzf - -C /var/lib/postgresql/data/pgdata' # call the method ret = runner.incremental_restore_cmd() diff --git a/backup/tests/unittests/drivers/test_xtrabackup.py b/backup/tests/unittests/drivers/test_xtrabackup.py index 8092db9a0c..a9ac972acd 100644 --- a/backup/tests/unittests/drivers/test_xtrabackup.py +++ b/backup/tests/unittests/drivers/test_xtrabackup.py @@ -68,9 +68,9 @@ class TestXtraBackup(unittest.TestCase): runner = self.runner_cls(**self.params) # assertions - cmd = (f'xtrabackup --backup --stream=xbstream --parallel=2 ' - f'--datadir=%(datadir)s --user=%(user)s ' - f'--password=%(password)s --host=%(host)s' + cmd = ('xtrabackup --backup --stream=xbstream --parallel=2 ' + '--datadir=%(datadir)s --user=%(user)s ' + '--password=%(password)s --host=%(host)s' % { 'datadir': runner.datadir, 'user': CONF.db_user, diff --git a/requirements.txt b/requirements.txt index b40c99c8ae..2f83bd203d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,3 @@ -# The order of packages is significant, because pip processes them in the order -# of appearance. Changing the order has an impact on the overall integration -# process, which may cause wedges in the gate later. pbr!=2.1.0,>=2.0.0 # Apache-2.0 SQLAlchemy!=1.1.5,!=1.1.6,!=1.1.7,!=1.1.8,>=1.0.10 # MIT eventlet!=0.18.3,!=0.20.1,>=0.18.2 # MIT @@ -53,4 +50,4 @@ oslo.cache>=1.26.0 # Apache-2.0 # for trove network driver Flask>=2.2.3 # BSD pyroute2>=0.7.7;sys_platform!='win32' # Apache-2.0 (+ dual licensed GPL2) -gunicorn>=20.1.0 # MIT \ No newline at end of file +gunicorn>=20.1.0 # MIT diff --git a/test-requirements.txt b/test-requirements.txt index bf696a251c..d01d750175 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,8 +1,5 @@ -# The order of packages is significant, because pip processes them in the order -# of appearance. Changing the order has an impact on the overall integration -# process, which may cause wedges in the gate later. # Hacking already pins down pep8, pyflakes and flake8 -hacking>=3.0.1,<3.1.0 # Apache-2.0 +hacking<6.0.0 # Apache-2.0 bandit[baseline]>=1.7.7 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 WebTest>=2.0.27 # MIT diff --git a/trove/common/models.py b/trove/common/models.py index 2cc247d05b..5f9478f5d0 100644 --- a/trove/common/models.py +++ b/trove/common/models.py @@ -67,7 +67,7 @@ class ModelBase(object): """Overloaded to cause this object to look like a data entity.""" if not hasattr(other, 'id'): return False - return type(other) == type(self) and other.id == self.id + return type(other) is type(self) and other.id == self.id def __ne__(self, other): """Overloaded to cause this object to look like a data entity.""" diff --git a/trove/common/stream_codecs.py b/trove/common/stream_codecs.py index 8a5cc98a42..b77dc4d898 100644 --- a/trove/common/stream_codecs.py +++ b/trove/common/stream_codecs.py @@ -506,9 +506,9 @@ class JsonCodec(StreamCodec): return jsonutils.dumps(dict_data) def deserialize(self, stream): - if type(stream) == str: + if isinstance(stream, str): return jsonutils.load(io.StringIO(stream)) - if type(stream) == bytes: + if isinstance(stream, bytes): return jsonutils.load(io.BytesIO(stream)) diff --git a/trove/common/wsgi.py b/trove/common/wsgi.py index 5231811dff..1e126385b3 100644 --- a/trove/common/wsgi.py +++ b/trove/common/wsgi.py @@ -40,7 +40,6 @@ from trove.common import pastedeploy from trove.common import utils CONTEXT_KEY = 'trove.context' -Router = base_wsgi.Router Debug = base_wsgi.Debug Middleware = base_wsgi.Middleware JSONDictSerializer = base_wsgi.JSONDictSerializer diff --git a/trove/hacking/checks.py b/trove/hacking/checks.py index a00a281446..61ddbf539c 100644 --- a/trove/hacking/checks.py +++ b/trove/hacking/checks.py @@ -12,8 +12,6 @@ import re -import pycodestyle - from hacking import core _all_log_levels = ( @@ -59,20 +57,19 @@ def check_raised_localized_exceptions(logical_line, filename): @core.flake8ext -def no_translate_logs(physical_line, logical_line, filename): +def no_translate_logs(logical_line, filename, noqa): """T105 - Log messages shouldn't be translated from the Pike release. :param logical_line: The logical line to check. - :param physical_line: The physical line to check. :param filename: The file name where the logical line exists. + :param noqa: whether the check should be skipped :returns: None if the logical line passes the check, otherwise a tuple is yielded that contains the offending index in logical line and a message describe the check validation failure. """ - if _translation_is_not_expected(filename): + if noqa: return - - if pycodestyle.noqa(physical_line): + if _translation_is_not_expected(filename): return msg = "T105: Log message shouldn't be translated." diff --git a/trove/instance/models.py b/trove/instance/models.py index bd9dfabba8..2d9b671b2e 100644 --- a/trove/instance/models.py +++ b/trove/instance/models.py @@ -505,7 +505,7 @@ class SimpleInstance(object): @property def access(self): if hasattr(self.db_info, 'access'): - if type(self.db_info.access) == str: + if isinstance(self.db_info.access, str): return json.loads(self.db_info.access) return self.db_info.access else: diff --git a/trove/tests/unittests/backup/test_backup_models.py b/trove/tests/unittests/backup/test_backup_models.py index 71b0f3a0e6..10466eea5f 100644 --- a/trove/tests/unittests/backup/test_backup_models.py +++ b/trove/tests/unittests/backup/test_backup_models.py @@ -208,9 +208,9 @@ class BackupCreateTest(trove_testtools.TestCase): instance = MagicMock() instance.cluster_id = 'bad_id' with patch.object(instance_models.BuiltInstance, 'load', - return_value=instance),\ + return_value=instance), \ patch.object(models.Backup, 'validate_can_perform_action', - return_value=None),\ + return_value=None), \ patch.object(models.Backup, 'verify_swift_auth_token', return_value=None): self.assertRaises(exception.ClusterInstanceOperationNotSupported, @@ -223,13 +223,13 @@ class BackupCreateTest(trove_testtools.TestCase): instance = MagicMock() instance.cluster_id = None with patch.object(instance_models.BuiltInstance, 'load', - return_value=instance),\ + return_value=instance), \ patch.object(models.Backup, 'validate_can_perform_action', - return_value=None),\ + return_value=None), \ patch.object(models.Backup, 'verify_swift_auth_token', - return_value=None),\ + return_value=None), \ patch.object(DatabaseModelBase, 'is_valid', - return_value=False),\ + return_value=False), \ patch('trove.quota.quota.QuotaEngine.reserve', return_value=[]): DatabaseModelBase.errors = {} diff --git a/trove/tests/unittests/hacking/test_check.py b/trove/tests/unittests/hacking/test_check.py index d09eabfc0d..f3b0d4ba84 100644 --- a/trove/tests/unittests/hacking/test_check.py +++ b/trove/tests/unittests/hacking/test_check.py @@ -41,24 +41,23 @@ class HackingTestCase(trove_testtools.TestCase): for level in all_log_levels: bad = 'LOG.%s(_("Bad"))' % level self.assertEqual( - 1, len(list(tc.no_translate_logs(bad, bad, 'f')))) + 1, len(list(tc.no_translate_logs(bad, 'f', False)))) bad = "LOG.%s(_('Bad'))" % level self.assertEqual( - 1, len(list(tc.no_translate_logs(bad, bad, 'f')))) + 1, len(list(tc.no_translate_logs(bad, 'f', False)))) ok = 'LOG.%s("OK")' % level self.assertEqual( - 0, len(list(tc.no_translate_logs(ok, ok, 'f')))) - ok = "LOG.%s(_('OK')) # noqa" % level + 0, len(list(tc.no_translate_logs(ok, 'f', False)))) + ok = "LOG.%s(_('OK'))" % level self.assertEqual( - 0, len(list(tc.no_translate_logs(ok, ok, 'f')))) + 0, len(list(tc.no_translate_logs(ok, 'f', True)))) ok = "LOG.%s(variable)" % level self.assertEqual( - 0, len(list(tc.no_translate_logs(ok, ok, 'f')))) + 0, len(list(tc.no_translate_logs(ok, 'f', False)))) # Do not do validations in tests ok = 'LOG.%s(_("OK - unit tests"))' % level self.assertEqual( - 0, len(list(tc.no_translate_logs(ok, ok, - 'f/tests/f')))) + 0, len(list(tc.no_translate_logs(ok, 'f/tests/f', False)))) def test_check_localized_exception_messages(self): f = tc.check_raised_localized_exceptions diff --git a/trove/tests/unittests/taskmanager/test_models.py b/trove/tests/unittests/taskmanager/test_models.py index 777fba7128..1bb6e84cf9 100644 --- a/trove/tests/unittests/taskmanager/test_models.py +++ b/trove/tests/unittests/taskmanager/test_models.py @@ -269,10 +269,8 @@ class FreshInstanceTasksTest(BaseFreshInstanceTasksTest): # execute files = self.freshinstancetasks.get_injected_files("test", 'test') # verify - self.assertTrue( - '/etc/trove/conf.d/guest_info.conf' in files) - self.assertTrue( - '/etc/trove/conf.d/trove-guestagent.conf' in files) + self.assertIn('/etc/trove/conf.d/guest_info.conf', files) + self.assertIn('/etc/trove/conf.d/trove-guestagent.conf', files) self.assertEqual( self.guestconfig_content, files['/etc/trove/conf.d/trove-guestagent.conf']) @@ -289,10 +287,8 @@ class FreshInstanceTasksTest(BaseFreshInstanceTasksTest): # execute files = self.freshinstancetasks.get_injected_files("test", 'test') # verify - self.assertTrue( - '/etc/guest_info' in files) - self.assertTrue( - '/etc/trove-guestagent.conf' in files) + self.assertIn('/etc/guest_info', files) + self.assertIn('/etc/trove-guestagent.conf', files) self.assertEqual( self.guestconfig_content, files['/etc/trove-guestagent.conf']) diff --git a/trove/volume_type/models.py b/trove/volume_type/models.py index 5080f73386..584f6a61a5 100644 --- a/trove/volume_type/models.py +++ b/trove/volume_type/models.py @@ -32,7 +32,7 @@ class VolumeType(object): @classmethod def load(cls, volume_type_id, context=None, client=None): - if not(client or context): + if not (client or context): raise trove_exception.InvalidModelError( "client or context must be provided to load a volume_type") if not client: