diff --git a/rally/common/utils.py b/rally/common/utils.py index 0bde1dc278..da49ac7bef 100644 --- a/rally/common/utils.py +++ b/rally/common/utils.py @@ -627,7 +627,7 @@ class LockedDict(dict): obj = dict(obj) for k, v in obj.items(): obj[k] = unlock(v) - elif type(obj) == tuple: + elif isinstance(obj, tuple): obj = tuple([unlock(v) for v in obj]) return obj return copy.deepcopy(unlock(self), memo=memo) diff --git a/rally/plugins/common/validators.py b/rally/plugins/common/validators.py index cf65b40c43..f8baea3734 100644 --- a/rally/plugins/common/validators.py +++ b/rally/plugins/common/validators.py @@ -147,7 +147,7 @@ class NumberValidator(validation.Validator): if self.integer_only: # NOTE(boris-42): Force check that passed value is not float, this # is important cause int(float_numb) won't raise exception - if type(value) == float: + if isinstance(value, float): return self.fail("%(name)s is %(val)s which hasn't int type" % {"name": self.param_name, "val": value}) num_func = int diff --git a/rally/task/processing/charts.py b/rally/task/processing/charts.py index b5b05c0f05..a717ca9bb1 100644 --- a/rally/task/processing/charts.py +++ b/rally/task/processing/charts.py @@ -914,7 +914,7 @@ def validate_output(output_type, output): proper_type = _OUTPUT_SCHEMA["key_types"][key] if not isinstance(output[key], proper_type): - if type(proper_type) == tuple: + if isinstance(proper_type, tuple): return ("Value of %(name)s output %(key)s has wrong type " "'%(actual_type)s', should be in %(types)r" % {"name": output_type, diff --git a/rally/task/service.py b/rally/task/service.py index b0637e1080..6970dddab8 100644 --- a/rally/task/service.py +++ b/rally/task/service.py @@ -131,7 +131,7 @@ class ServiceMeta(type): def __init__(cls, name, bases, namespaces): super(ServiceMeta, cls).__init__(name, bases, namespaces) - bases = [c for c in cls.__bases__ if type(c) == ServiceMeta] + bases = [c for c in cls.__bases__ if isinstance(c, ServiceMeta)] if not bases: # nothing to check return diff --git a/rally/task/sla.py b/rally/task/sla.py index 473b374ad3..c085409845 100644 --- a/rally/task/sla.py +++ b/rally/task/sla.py @@ -178,7 +178,7 @@ class SLA(plugin.Plugin, validation.ValidatablePluginMixin, """ def validate_type(self, other): - if type(self) != type(other): + if type(self) is not type(other): raise TypeError( "Error merging SLAs of types %s, %s. Only SLAs of the same " "type could be merged." % (type(self), type(other))) diff --git a/tests/unit/cli/test_cliutils.py b/tests/unit/cli/test_cliutils.py index 80dc12000b..5c675e7212 100644 --- a/tests/unit/cli/test_cliutils.py +++ b/tests/unit/cli/test_cliutils.py @@ -196,7 +196,7 @@ class CliUtilsTestCase(test.TestCase): @ddt.unpack def test_pretty_float_formatter(self, obj, args, expected=None): formatter = cliutils.pretty_float_formatter(*args) - if type(expected) == type and issubclass(expected, Exception): + if type(expected) is type and issubclass(expected, Exception): self.assertRaises(expected, formatter, obj) else: self.assertEqual(expected, formatter(obj)) diff --git a/tests/unit/task/test_hook.py b/tests/unit/task/test_hook.py index 95330fef63..bad9afe668 100644 --- a/tests/unit/task/test_hook.py +++ b/tests/unit/task/test_hook.py @@ -170,7 +170,7 @@ class HookExecutorTestCase(test.TestCase): self.assertEqual( [{ "config": self.conf["hooks"][0], - "results":[ + "results": [ { "triggered_by": {"event_type": "time", "value": 2}, "started_at": fakes.FakeTimer().timestamp(),