diff --git a/test-requirements.txt b/test-requirements.txt index 8e2b35813..a6810b6ac 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -5,7 +5,7 @@ coverage>=4.5.1 # Apache-2.0 doc8>=0.8.0 # Apache-2.0 freezegun>=0.3.10 # Apache-2.0 -hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 +hacking>=1.1.0,<1.2.0 # Apache-2.0 mock>=2.0.0 # BSD oslotest>=3.3.0 # Apache-2.0 os-testr>=1.0.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini index ea2ae04d4..6593b30dd 100644 --- a/tox.ini +++ b/tox.ini @@ -72,7 +72,7 @@ commands = [flake8] filename = *.py,app.wsgi show-source=True -ignore= H105,E123,E226,N320,H202 +ignore= H105,E123,E226,E731,N320,H202 builtins= _ enable-extensions = H106,H203,H904 exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,*sqlalchemy/alembic/versions/*,demo/,releasenotes diff --git a/watcher/api/controllers/v1/audit.py b/watcher/api/controllers/v1/audit.py index 993f7f504..7ea89d92e 100644 --- a/watcher/api/controllers/v1/audit.py +++ b/watcher/api/controllers/v1/audit.py @@ -123,8 +123,8 @@ class AuditPostType(wtypes.Base): 'or goal should be provided.') if (self.audit_type == objects.audit.AuditType.ONESHOT.value and - (self.start_time not in (wtypes.Unset, None) - or self.end_time not in (wtypes.Unset, None))): + (self.start_time not in (wtypes.Unset, None) or + self.end_time not in (wtypes.Unset, None))): raise exception.AuditStartEndTimeNotAllowed( audit_type=self.audit_type) diff --git a/watcher/api/controllers/v1/service.py b/watcher/api/controllers/v1/service.py index 9401031d0..eb047aee2 100644 --- a/watcher/api/controllers/v1/service.py +++ b/watcher/api/controllers/v1/service.py @@ -69,8 +69,8 @@ class Service(base.APIBase): def _set_status(self, id): service = objects.Service.get(pecan.request.context, id) - last_heartbeat = (service.last_seen_up or service.updated_at - or service.created_at) + last_heartbeat = (service.last_seen_up or service.updated_at or + service.created_at) if isinstance(last_heartbeat, six.string_types): # NOTE(russellb) If this service came in over rpc via # conductor, then the timestamp will be a string and needs to be diff --git a/watcher/api/scheduling.py b/watcher/api/scheduling.py index 3cdd05be8..f00bd1cc8 100644 --- a/watcher/api/scheduling.py +++ b/watcher/api/scheduling.py @@ -82,8 +82,8 @@ class APISchedulingService(scheduling.BackgroundSchedulerService): def get_service_status(self, context, service_id): service = objects.Service.get(context, service_id) - last_heartbeat = (service.last_seen_up or service.updated_at - or service.created_at) + last_heartbeat = (service.last_seen_up or service.updated_at or + service.created_at) if isinstance(last_heartbeat, six.string_types): # NOTE(russellb) If this service came in over rpc via # conductor, then the timestamp will be a string and needs to be diff --git a/watcher/decision_engine/goal/efficacy/specs.py b/watcher/decision_engine/goal/efficacy/specs.py index 66a9b1a97..7997d7b35 100644 --- a/watcher/decision_engine/goal/efficacy/specs.py +++ b/watcher/decision_engine/goal/efficacy/specs.py @@ -100,9 +100,9 @@ class HardwareMaintenance(base.EfficacySpecification): if (indicators_map and indicators_map.planned_live_migrate_instance_count > 0): li_value = ( - float(indicators_map.planned_live_migrate_instance_count) - / float(indicators_map.live_migrate_instance_count) - * 100 + float(indicators_map.planned_live_migrate_instance_count) / + float(indicators_map.live_migrate_instance_count) * + 100 ) li_indicator = efficacy.Indicator( @@ -116,9 +116,9 @@ class HardwareMaintenance(base.EfficacySpecification): if (indicators_map and indicators_map.planned_cold_migrate_instance_count > 0): ci_value = ( - float(indicators_map.planned_cold_migrate_instance_count) - / float(indicators_map.cold_migrate_instance_count) - * 100 + float(indicators_map.planned_cold_migrate_instance_count) / + float(indicators_map.cold_migrate_instance_count) * + 100 ) ci_indicator = efficacy.Indicator( @@ -133,8 +133,8 @@ class HardwareMaintenance(base.EfficacySpecification): indicators_map.planned_volume_migrate_count > 0): dv_value = (float(indicators_map.planned_volume_migrate_count) / float(indicators_map. - volume_migrate_count) - * 100) + volume_migrate_count) * + 100) dv_indicator = efficacy.Indicator( name="volume_migrate_ratio", @@ -148,8 +148,8 @@ class HardwareMaintenance(base.EfficacySpecification): indicators_map.planned_volume_update_count > 0): av_value = (float(indicators_map.planned_volume_update_count) / float(indicators_map. - volume_update_count) - * 100) + volume_update_count) * + 100) av_indicator = efficacy.Indicator( name="volume_update_ratio", diff --git a/watcher/decision_engine/strategy/strategies/zone_migration.py b/watcher/decision_engine/strategy/strategies/zone_migration.py index 3d2fd5db7..6d748b752 100644 --- a/watcher/decision_engine/strategy/strategies/zone_migration.py +++ b/watcher/decision_engine/strategy/strategies/zone_migration.py @@ -535,8 +535,8 @@ class ZoneMigration(base.ZoneMigrationBaseStrategy): return None return [i for i in self.nova.get_instance_list() - if getattr(i, 'OS-EXT-SRV-ATTR:host') in src_node_list - and self.compute_model.get_instance_by_uuid(i.id)] + if getattr(i, 'OS-EXT-SRV-ATTR:host') in src_node_list and + self.compute_model.get_instance_by_uuid(i.id)] def get_volumes(self): """Get migrate target volumes @@ -547,8 +547,8 @@ class ZoneMigration(base.ZoneMigrationBaseStrategy): src_pool_list = self.get_src_pool_list() return [i for i in self.cinder.get_volume_list() - if getattr(i, 'os-vol-host-attr:host') in src_pool_list - and self.storage_model.get_volume_by_uuid(i.id)] + if getattr(i, 'os-vol-host-attr:host') in src_pool_list and + self.storage_model.get_volume_by_uuid(i.id)] def filtered_targets(self): """Filter targets diff --git a/watcher/tests/api/test_hooks.py b/watcher/tests/api/test_hooks.py index 5ae229c3b..8ed737023 100644 --- a/watcher/tests/api/test_hooks.py +++ b/watcher/tests/api/test_hooks.py @@ -144,8 +144,8 @@ class TestNoExceptionTracebackHook(base.FunctionalTest): # rare thing (happens due to wrong deserialization settings etc.) # we don't care about this garbage. expected_msg = ("Remote error: %s %s" - % (test_exc_type, self.MSG_WITHOUT_TRACE) - + ("\n[u'" if six.PY2 else "\n['")) + % (test_exc_type, self.MSG_WITHOUT_TRACE) + + ("\n[u'" if six.PY2 else "\n['")) actual_msg = jsonutils.loads( response.json['error_message'])['faultstring'] self.assertEqual(expected_msg, actual_msg) diff --git a/watcher/tests/api/v1/test_actions_plans.py b/watcher/tests/api/v1/test_actions_plans.py index 76b190305..6011dda91 100644 --- a/watcher/tests/api/v1/test_actions_plans.py +++ b/watcher/tests/api/v1/test_actions_plans.py @@ -550,10 +550,10 @@ class TestPatchStateTransitionDenied(api_base.FunctionalTest): # because we cannot retrieve them with a GET (soft_deleted state). # This is the reason why they are not listed here but they have a # special test to cover it - if original_state != objects.action_plan.State.DELETED - and original_state != new_state - and {"original_state": original_state, - "new_state": new_state} not in ALLOWED_TRANSITIONS + if original_state != objects.action_plan.State.DELETED and + original_state != new_state and + {"original_state": original_state, + "new_state": new_state} not in ALLOWED_TRANSITIONS ] def setUp(self): diff --git a/watcher/tests/api/v1/test_audits.py b/watcher/tests/api/v1/test_audits.py index 004709962..faab6ded7 100644 --- a/watcher/tests/api/v1/test_audits.py +++ b/watcher/tests/api/v1/test_audits.py @@ -384,9 +384,9 @@ class TestPatchStateTransitionDenied(api_base.FunctionalTest): ) for original_state, new_state in list(itertools.product(STATES, STATES)) - if original_state != new_state - and {"original_state": original_state, - "new_state": new_state} not in ALLOWED_TRANSITIONS + if original_state != new_state and + {"original_state": original_state, + "new_state": new_state} not in ALLOWED_TRANSITIONS ] def setUp(self):