From c3c4839514aec416c01e8bee903b69587b7eacc7 Mon Sep 17 00:00:00 2001 From: Dina Belova Date: Wed, 25 Jun 2014 12:47:56 +0400 Subject: [PATCH] Fix E128 violations and re-enable gating E128 got stricter in hacking 0.9, so fix new violations and re-enable gating. Change-Id: Id061f154f97d78bbbcd8704e6213034cce90a841 --- ceilometer/alarm/partition/coordination.py | 2 +- ceilometer/compute/pollsters/net.py | 4 +- ceilometer/hardware/inspector/snmp.py | 4 +- .../versions/030_rename_meter_table.py | 12 ++--- .../tests/alarm/evaluator/test_combination.py | 6 +-- .../api/v2/test_list_meters_scenarios.py | 46 +++++++++---------- .../compute/virt/libvirt/test_inspector.py | 10 ++-- .../tests/storage/test_impl_sqlalchemy.py | 10 ++-- .../tests/storage/test_storage_scenarios.py | 11 ++--- tox.ini | 3 +- 10 files changed, 53 insertions(+), 55 deletions(-) diff --git a/ceilometer/alarm/partition/coordination.py b/ceilometer/alarm/partition/coordination.py index 828362e9b..e013ab616 100644 --- a/ceilometer/alarm/partition/coordination.py +++ b/ceilometer/alarm/partition/coordination.py @@ -240,7 +240,7 @@ class PartitionCoordinator(object): still_ahead = self.this < self.oldest self.last_alarms = set(alarms) LOG.info(_('%(this)s not overtaken as master? %(still_ahead)s') % - ({'this': self.this, 'still_ahead': still_ahead})) + ({'this': self.this, 'still_ahead': still_ahead})) return still_ahead def check_mastership(self, eval_interval, api_client): diff --git a/ceilometer/compute/pollsters/net.py b/ceilometer/compute/pollsters/net.py index e1320c3b1..4df105d3b 100644 --- a/ceilometer/compute/pollsters/net.py +++ b/ceilometer/compute/pollsters/net.py @@ -117,8 +117,8 @@ class _Base(plugin.ComputePollster): class _RateBase(_Base): NET_USAGE_MESSAGE = ' '.join(["NETWORK RATE:", "%s %s:", - "read-bytes-rate=%d", - "write-bytes-rate=%d"]) + "read-bytes-rate=%d", + "write-bytes-rate=%d"]) CACHE_KEY_VNIC = 'vnic-rates' diff --git a/ceilometer/hardware/inspector/snmp.py b/ceilometer/hardware/inspector/snmp.py index a408695a2..f773accd0 100644 --- a/ceilometer/hardware/inspector/snmp.py +++ b/ceilometer/hardware/inspector/snmp.py @@ -95,8 +95,8 @@ class SNMPInspector(base.Inspector): (error, data) = parse_snmp_return(ret) if error: raise SNMPException("An error occurred, oid %(oid)s, " - "host %(host)s, %(err)s" % dict(oid=oid, - host=host.hostname, err=data)) + "host %(host)s, %(err)s" % + dict(oid=oid, host=host.hostname, err=data)) else: return ret_func(data) diff --git a/ceilometer/storage/sqlalchemy/migrate_repo/versions/030_rename_meter_table.py b/ceilometer/storage/sqlalchemy/migrate_repo/versions/030_rename_meter_table.py index 269bc2fdf..6e27074a5 100644 --- a/ceilometer/storage/sqlalchemy/migrate_repo/versions/030_rename_meter_table.py +++ b/ceilometer/storage/sqlalchemy/migrate_repo/versions/030_rename_meter_table.py @@ -37,16 +37,16 @@ def _handle_meter_indices(meta, downgrade=False): fk_params = [({'columns': [meter.c.resource_id], 'refcolumns': [resource.c.id]}, - 'fk_meter_resource_id', - 'fk_sample_resource_id'), + 'fk_meter_resource_id', + 'fk_sample_resource_id'), ({'columns': [meter.c.project_id], 'refcolumns': [project.c.id]}, - 'fk_meter_project_id', - 'fk_sample_project_id'), + 'fk_meter_project_id', + 'fk_sample_project_id'), ({'columns': [meter.c.user_id], 'refcolumns': [user.c.id]}, - 'fk_meter_user_id', - 'fk_sample_user_id')] + 'fk_meter_user_id', + 'fk_sample_user_id')] for fk in fk_params: params = fk[0] diff --git a/ceilometer/tests/alarm/evaluator/test_combination.py b/ceilometer/tests/alarm/evaluator/test_combination.py index cc36d34a9..504caa038 100644 --- a/ceilometer/tests/alarm/evaluator/test_combination.py +++ b/ceilometer/tests/alarm/evaluator/test_combination.py @@ -88,16 +88,16 @@ class TestEvaluate(base.TestEvaluatorBase): def _combination_transition_reason(self, state, alarm_ids1, alarm_ids2): return ([('Transition to %(state)s due to alarms %(alarm_ids)s' - ' in state %(state)s') + ' in state %(state)s') % {'state': state, 'alarm_ids': ",".join(alarm_ids1)}, ('Transition to %(state)s due to alarms %(alarm_ids)s' - ' in state %(state)s') + ' in state %(state)s') % {'state': state, 'alarm_ids': ",".join(alarm_ids2)}], [self._reason_data(alarm_ids1), self._reason_data(alarm_ids2)]) def _combination_remaining_reason(self, state, alarm_ids1, alarm_ids2): return ([('Remaining as %(state)s due to alarms %(alarm_ids)s' - ' in state %(state)s') + ' in state %(state)s') % {'state': state, 'alarm_ids': ",".join(alarm_ids1)}, ('Remaining as %(state)s due to alarms %(alarm_ids)s' ' in state %(state)s') diff --git a/ceilometer/tests/api/v2/test_list_meters_scenarios.py b/ceilometer/tests/api/v2/test_list_meters_scenarios.py index 68735c90e..dc0a41389 100644 --- a/ceilometer/tests/api/v2/test_list_meters_scenarios.py +++ b/ceilometer/tests/api/v2/test_list_meters_scenarios.py @@ -44,21 +44,21 @@ class TestValidateUserInput(v2.FunctionalTest, self.assertRaises(webtest.app.AppError, self.get_json, '/meters/meter.test', q=[{'field': 'metadata.util', - 'op': 'eq', - 'value': '0.7.5', - 'type': 'float'}]) + 'op': 'eq', + 'value': '0.7.5', + 'type': 'float'}]) self.assertRaises(webtest.app.AppError, self.get_json, '/meters/meter.test', q=[{'field': 'metadata.util', - 'op': 'eq', - 'value': 'abacaba', - 'type': 'boolean'}]) + 'op': 'eq', + 'value': 'abacaba', + 'type': 'boolean'}]) self.assertRaises(webtest.app.AppError, self.get_json, '/meters/meter.test', q=[{'field': 'metadata.util', - 'op': 'eq', - 'value': '45.765', - 'type': 'integer'}]) + 'op': 'eq', + 'value': '45.765', + 'type': 'integer'}]) class TestListMeters(v2.FunctionalTest, @@ -260,9 +260,9 @@ class TestListMeters(v2.FunctionalTest, def test_list_meters_query_wrong_type_metadata(self): resp = self.get_json('/meters/meter.test', q=[{'field': 'metadata.size', - 'op': 'eq', - 'value': '0', - 'type': 'blob'}], + 'op': 'eq', + 'value': '0', + 'type': 'blob'}], expect_errors=True ) expected_error_message = 'The data type blob is not supported.' @@ -400,9 +400,9 @@ class TestListMeters(v2.FunctionalTest, def test_list_meters_query_integer_metadata(self): data = self.get_json('/meters/meter.test', q=[{'field': 'metadata.size', - 'op': 'eq', - 'value': '0', - 'type': 'integer'}] + 'op': 'eq', + 'value': '0', + 'type': 'integer'}] ) self.assertEqual(2, len(data)) self.assertEqual(set(['resource-id', @@ -416,9 +416,9 @@ class TestListMeters(v2.FunctionalTest, def test_list_meters_query_float_metadata(self): data = self.get_json('/meters/meter.test', q=[{'field': 'metadata.util', - 'op': 'eq', - 'value': '0.75', - 'type': 'float'}] + 'op': 'eq', + 'value': '0.75', + 'type': 'float'}] ) self.assertEqual(2, len(data)) self.assertEqual(set(['resource-id', @@ -432,9 +432,9 @@ class TestListMeters(v2.FunctionalTest, def test_list_meters_query_boolean_metadata(self): data = self.get_json('/meters/meter.mine', q=[{'field': 'metadata.is_public', - 'op': 'eq', - 'value': 'False', - 'type': 'boolean'}] + 'op': 'eq', + 'value': 'False', + 'type': 'boolean'}] ) self.assertEqual(1, len(data)) self.assertEqual(set(['resource-id2']), @@ -448,8 +448,8 @@ class TestListMeters(v2.FunctionalTest, def test_list_meters_query_string_metadata(self): data = self.get_json('/meters/meter.test', q=[{'field': 'metadata.tag', - 'op': 'eq', - 'value': 'self.sample'}] + 'op': 'eq', + 'value': 'self.sample'}] ) self.assertEqual(1, len(data)) self.assertEqual(set(['resource-id']), diff --git a/ceilometer/tests/compute/virt/libvirt/test_inspector.py b/ceilometer/tests/compute/virt/libvirt/test_inspector.py index 2d42771b4..0df73da35 100644 --- a/ceilometer/tests/compute/virt/libvirt/test_inspector.py +++ b/ceilometer/tests/compute/virt/libvirt/test_inspector.py @@ -148,7 +148,7 @@ class TestLibvirtInspection(test.BaseTestCase): side_effect=interfaceStats), mock.patch.object(self.domain, 'info', return_value=(0L, 0L, 0L, - 2L, 999999L))): + 2L, 999999L))): interfaces = list(self.inspector.inspect_vnics(self.instance_name)) self.assertEqual(3, len(interfaces)) @@ -194,7 +194,7 @@ class TestLibvirtInspection(test.BaseTestCase): return_value=self.domain), mock.patch.object(self.domain, 'info', return_value=(5L, 0L, 0L, - 2L, 999999L))): + 2L, 999999L))): interfaces = list(self.inspector.inspect_vnics(self.instance_name)) self.assertEqual(interfaces, []) @@ -221,10 +221,10 @@ class TestLibvirtInspection(test.BaseTestCase): return_value=dom_xml), mock.patch.object(self.domain, 'blockStats', return_value=(1L, 2L, 3L, - 4L, -1)), + 4L, -1)), mock.patch.object(self.domain, 'info', return_value=(0L, 0L, 0L, - 2L, 999999L))): + 2L, 999999L))): disks = list(self.inspector.inspect_disks(self.instance_name)) self.assertEqual(1, len(disks)) @@ -241,7 +241,7 @@ class TestLibvirtInspection(test.BaseTestCase): return_value=self.domain), mock.patch.object(self.domain, 'info', return_value=(5L, 0L, 0L, - 2L, 999999L))): + 2L, 999999L))): disks = list(self.inspector.inspect_disks(self.instance_name)) self.assertEqual(disks, []) diff --git a/ceilometer/tests/storage/test_impl_sqlalchemy.py b/ceilometer/tests/storage/test_impl_sqlalchemy.py index 4806334d5..9c6e9bfb5 100644 --- a/ceilometer/tests/storage/test_impl_sqlalchemy.py +++ b/ceilometer/tests/storage/test_impl_sqlalchemy.py @@ -186,11 +186,11 @@ class RelationshipTest(scenarios.DBTestBase): meta_tables = [sql_models.MetaText, sql_models.MetaFloat, sql_models.MetaBigInt, sql_models.MetaBool] for table in meta_tables: - self.assertEqual(0, session.query(table) - .filter(~table.id.in_( - session.query(sql_models.Sample.id) - .group_by(sql_models.Sample.id) - )).count()) + self.assertEqual(0, (session.query(table) + .filter(~table.id.in_( + session.query(sql_models.Sample.id) + .group_by(sql_models.Sample.id))).count() + )) class CapabilitiesTest(test_base.BaseTestCase): diff --git a/ceilometer/tests/storage/test_storage_scenarios.py b/ceilometer/tests/storage/test_storage_scenarios.py index a90a02390..421b094ef 100644 --- a/ceilometer/tests/storage/test_storage_scenarios.py +++ b/ceilometer/tests/storage/test_storage_scenarios.py @@ -934,7 +934,7 @@ class ComplexSampleQueryTest(DBTestBase, for sample in results: self.assertTrue((sample.resource_metadata["a_string_key"] == "meta-value0.81" or - sample.resource_metadata["a_float_key"] <= 0.41)) + sample.resource_metadata["a_float_key"] <= 0.41)) self.assertTrue(sample.resource_metadata["an_int_key"] > 42) def test_query_mixed_data_and_metadata_filter(self): @@ -952,7 +952,7 @@ class ComplexSampleQueryTest(DBTestBase, for sample in results: self.assertTrue((sample.resource_metadata["a_string_key"] == "meta-value0.81" or - sample.resource_metadata["a_float_key"] <= 0.41)) + sample.resource_metadata["a_float_key"] <= 0.41)) self.assertEqual(sample.resource_id, "resource-id-42") def test_query_non_existing_metadata_with_result(self): @@ -2545,7 +2545,7 @@ class ComplexAlarmQueryTest(AlarmTestBase, [{"or": [{"=": {"name": "yellow-alert"}}, {"=": {"name": "red-alert"}}]}, - {"=": {"enabled": True}}]} + {"=": {"enabled": True}}]} result = list(self.conn.query_alarms(filter_expr=filter_expr)) @@ -2566,9 +2566,8 @@ class ComplexAlarmQueryTest(AlarmTestBase, def test_filter_and_orderby(self): self.add_some_alarms() - result = list(self.conn.query_alarms(filter_expr={"=": - {"enabled": - True}}, + result = list(self.conn.query_alarms(filter_expr= + {"=": {"enabled": True}}, orderby=[{"name": "asc"}])) self.assertEqual(2, len(result)) self.assertEqual(["orange-alert", "red-alert"], diff --git a/tox.ini b/tox.ini index f20c8f9b2..03df72b15 100644 --- a/tox.ini +++ b/tox.ini @@ -37,7 +37,6 @@ commands = python setup.py build_sphinx commands = {posargs} [flake8] -# E128 continuation line under-indented for visual indent # E251 unexpected spaces around keyword / parameter equals # E265 block comment should start with ‘# ‘ # F402 import module shadowed by loop variable @@ -45,7 +44,7 @@ commands = {posargs} # H307 like imports should be grouped together # H405 multi line docstring summary not separated with an empty line # H904 Wrap long lines in parentheses instead of a backslash -ignore = E128,E251,E265,F402,H305,H307,H405,H904 +ignore = E251,E265,F402,H305,H307,H405,H904 builtins = _ exclude=.venv,.git,.tox,dist,doc,./ceilometer/openstack/common,*lib/python*,*egg,tools,nova_tests,build show-source = True