From 11eb4e9d3e3df0acf5d668b9b1c5c14dff8146c1 Mon Sep 17 00:00:00 2001
From: Akihiro Motoki <amotoki@gmail.com>
Date: Wed, 11 Apr 2018 18:13:47 +0900
Subject: [PATCH] Fix W503 warnings

W503 line break before binary operator

Looking at the code base, it sounds okay to follow this check.

Change-Id: Id511e0104dc6de5b204021661d4a8776ca6d3658
---
 horizon/notifications.py                      |  4 +-
 horizon/tables/base.py                        | 14 ++--
 horizon/tables/views.py                       |  4 +-
 horizon/test/firefox_binary.py                |  4 +-
 horizon/utils/file_discovery.py               |  8 +--
 openstack_auth/user.py                        |  8 +--
 openstack_auth/utils.py                       |  4 +-
 .../admin/hypervisors/compute/tests.py        | 16 ++---
 .../dashboards/admin/images/views.py          |  4 +-
 .../dashboards/admin/instances/tables.py      | 10 +--
 .../admin/networks/ports/workflows.py         |  4 +-
 .../dashboards/admin/trunks/panel.py          |  8 +--
 .../dashboards/identity/groups/tables.py      |  4 +-
 .../project/images/images/tables.py           |  5 +-
 .../dashboards/project/instances/tables.py    | 72 +++++++++----------
 .../instances/workflows/create_instance.py    |  5 +-
 .../dashboards/project/network_qos/panel.py   |  7 +-
 .../project/network_topology/views.py         | 12 ++--
 .../project/networks/ports/views.py           |  5 +-
 .../project/networks/ports/workflows.py       |  8 +--
 .../routers/extensions/extraroutes/tables.py  |  4 +-
 .../dashboards/project/routers/ports/forms.py |  4 +-
 .../project/security_groups/tables.py         |  6 +-
 .../dashboards/project/server_groups/panel.py |  4 +-
 .../dashboards/project/trunks/panel.py        |  8 +--
 .../dashboards/project/volumes/tables.py      | 12 ++--
 .../dashboards/project/volumes/views.py       |  4 +-
 .../access_and_security/apiaccesspage.py      |  5 +-
 .../access_and_security/floatingipspage.py    |  2 +-
 .../test/unit/api/rest/test_neutron.py        |  3 +-
 .../test/unit/api/test_neutron.py             | 10 +--
 openstack_dashboard/utils/settings.py         | 10 +--
 tox.ini                                       |  3 +-
 33 files changed, 141 insertions(+), 140 deletions(-)

diff --git a/horizon/notifications.py b/horizon/notifications.py
index bde48124f9..94ef4e798f 100644
--- a/horizon/notifications.py
+++ b/horizon/notifications.py
@@ -143,8 +143,8 @@ def process_message_notification(request, messages_path):
     # NOTE (lhcheng): Cache the processed messages to avoid parsing
     # the files every time. Check directory modification time if
     # reload is necessary.
-    if (_MESSAGES_CACHE is None
-            or _MESSAGES_MTIME != os.path.getmtime(messages_path)):
+    if (_MESSAGES_CACHE is None or
+            _MESSAGES_MTIME != os.path.getmtime(messages_path)):
         _MESSAGES_CACHE = _get_processed_messages(messages_path)
         _MESSAGES_MTIME = os.path.getmtime(messages_path)
 
diff --git a/horizon/tables/base.py b/horizon/tables/base.py
index a55ea88004..6b9a4a4975 100644
--- a/horizon/tables/base.py
+++ b/horizon/tables/base.py
@@ -1072,8 +1072,8 @@ class DataTableOptions(object):
     """
     def __init__(self, options):
         self.name = getattr(options, 'name', self.__class__.__name__)
-        verbose_name = (getattr(options, 'verbose_name', None)
-                        or self.name.title())
+        verbose_name = (getattr(options, 'verbose_name', None) or
+                        self.name.title())
         self.verbose_name = verbose_name
         self.columns = getattr(options, 'columns', None)
         self.status_columns = getattr(options, 'status_columns', [])
@@ -1330,12 +1330,12 @@ class DataTable(object):
                 filter_string = self.get_filter_string()
                 filter_field = self.get_filter_field()
                 request_method = self.request.method
-                needs_preloading = (not filter_string
-                                    and request_method == 'GET'
-                                    and action.needs_preloading)
+                needs_preloading = (not filter_string and
+                                    request_method == 'GET' and
+                                    action.needs_preloading)
                 valid_method = (request_method == action.method)
-                not_api_filter = (filter_string
-                                  and not action.is_api_filter(filter_field))
+                not_api_filter = (filter_string and
+                                  not action.is_api_filter(filter_field))
 
                 if valid_method or needs_preloading or not_api_filter:
                     if self._meta.mixed_data_type:
diff --git a/horizon/tables/views.py b/horizon/tables/views.py
index 62d2cf3c72..172e979a37 100644
--- a/horizon/tables/views.py
+++ b/horizon/tables/views.py
@@ -138,8 +138,8 @@ class MultiTableMixin(object):
         param_name = filter_action.get_param_name()
         filter_string = request.POST.get(param_name)
         filter_string_session = request.session.get(param_name, "")
-        changed = (filter_string is not None
-                   and filter_string != filter_string_session)
+        changed = (filter_string is not None and
+                   filter_string != filter_string_session)
         if filter_string is None:
             filter_string = filter_string_session
         filter_field_param = param_name + '_field'
diff --git a/horizon/test/firefox_binary.py b/horizon/test/firefox_binary.py
index c836b5e0ff..e2c4a058d8 100644
--- a/horizon/test/firefox_binary.py
+++ b/horizon/test/firefox_binary.py
@@ -91,8 +91,8 @@ class WebDriver(firefox.webdriver.WebDriver):
                               'connection refused.' % i)
                     break
                 except socket.error as socket_error:
-                    if (socket_error.errno == errno.ECONNREFUSED
-                            and i < self.CONNREFUSED_RETRY_COUNT):
+                    if (socket_error.errno == errno.ECONNREFUSED and
+                            i < self.CONNREFUSED_RETRY_COUNT):
                         time.sleep(self.CONNREFUSED_RETRY_INTERVAL)
                         continue
                     raise
diff --git a/horizon/utils/file_discovery.py b/horizon/utils/file_discovery.py
index 40477f9d88..be034a5451 100644
--- a/horizon/utils/file_discovery.py
+++ b/horizon/utils/file_discovery.py
@@ -63,10 +63,10 @@ def sort_js_files(js_files):
     mocks = [f for f in js_files if f.endswith(MOCK_EXT)]
     specs = [f for f in js_files if f.endswith(SPEC_EXT)]
 
-    other_sources = [f for f in js_files if
-                     not f.endswith(MODULE_EXT)
-                     and not f.endswith(MOCK_EXT)
-                     and not f.endswith(SPEC_EXT)]
+    other_sources = [f for f in js_files
+                     if (not f.endswith(MODULE_EXT) and
+                         not f.endswith(MOCK_EXT) and
+                         not f.endswith(SPEC_EXT))]
 
     sources = modules + other_sources
     return sources, mocks, specs
diff --git a/openstack_auth/user.py b/openstack_auth/user.py
index 964c8a8f91..3532ec0d5e 100644
--- a/openstack_auth/user.py
+++ b/openstack_auth/user.py
@@ -128,8 +128,8 @@ class Token(object):
         """Determines if this is a pki-based token (pki or pkiz)"""
         if token is None:
             return False
-        return (keystone_cms.is_ans1_token(token)
-                or keystone_cms.is_pkiz(token))
+        return (keystone_cms.is_ans1_token(token) or
+                keystone_cms.is_pkiz(token))
 
 
 class User(models.AbstractBaseUser, models.AnonymousUser):
@@ -229,8 +229,8 @@ class User(models.AbstractBaseUser, models.AnonymousUser):
         self.project_name = project_name or tenant_name
         self.service_catalog = service_catalog
         self._services_region = (
-            services_region
-            or utils.default_services_region(service_catalog)
+            services_region or
+            utils.default_services_region(service_catalog)
         )
         self.roles = roles or []
         self.endpoint = endpoint
diff --git a/openstack_auth/utils.py b/openstack_auth/utils.py
index 53008736f0..d84489da42 100644
--- a/openstack_auth/utils.py
+++ b/openstack_auth/utils.py
@@ -352,8 +352,8 @@ def default_services_region(service_catalog, request=None,
         available_regions = [get_endpoint_region(endpoint) for service
                              in service_catalog for endpoint
                              in service.get('endpoints', [])
-                             if (service.get('type') is not None
-                                 and service.get('type') != 'identity')]
+                             if (service.get('type') is not None and
+                                 service.get('type') != 'identity')]
         if not available_regions:
             # this is very likely an incomplete keystone setup
             LOG.warning('No regions could be found excluding identity.')
diff --git a/openstack_dashboard/dashboards/admin/hypervisors/compute/tests.py b/openstack_dashboard/dashboards/admin/hypervisors/compute/tests.py
index 42f2ce44ba..9a652d1caa 100644
--- a/openstack_dashboard/dashboards/admin/hypervisors/compute/tests.py
+++ b/openstack_dashboard/dashboards/admin/hypervisors/compute/tests.py
@@ -98,8 +98,8 @@ class EvacuateHostViewTest(test.BaseAdminViewTests):
 class MigrateHostViewTest(test.BaseAdminViewTests):
     def test_index(self):
         disabled_services = [service for service in self.services.list()
-                             if service.binary == 'nova-compute'
-                             and service.status == 'disabled']
+                             if (service.binary == 'nova-compute' and
+                                 service.status == 'disabled')]
         disabled_service = disabled_services[0]
 
         url = reverse('horizon:admin:hypervisors:compute:migrate_host',
@@ -112,8 +112,8 @@ class MigrateHostViewTest(test.BaseAdminViewTests):
     @test.create_mocks({api.nova: ['migrate_host']})
     def test_maintenance_host_cold_migration_succeed(self):
         disabled_services = [service for service in self.services.list()
-                             if service.binary == 'nova-compute'
-                             and service.status == 'disabled']
+                             if (service.binary == 'nova-compute' and
+                                 service.status == 'disabled')]
         disabled_service = disabled_services[0]
         self.mock_migrate_host.return_value = True
 
@@ -139,8 +139,8 @@ class MigrateHostViewTest(test.BaseAdminViewTests):
     @test.create_mocks({api.nova: ['migrate_host']})
     def test_maintenance_host_live_migration_succeed(self):
         disabled_services = [service for service in self.services.list()
-                             if service.binary == 'nova-compute'
-                             and service.status == 'disabled']
+                             if (service.binary == 'nova-compute' and
+                                 service.status == 'disabled')]
         disabled_service = disabled_services[0]
         self.mock_migrate_host.return_value = True
         url = reverse('horizon:admin:hypervisors:compute:migrate_host',
@@ -165,8 +165,8 @@ class MigrateHostViewTest(test.BaseAdminViewTests):
     @test.create_mocks({api.nova: ['migrate_host']})
     def test_maintenance_host_migration_fails(self):
         disabled_services = [service for service in self.services.list()
-                             if service.binary == 'nova-compute'
-                             and service.status == 'disabled']
+                             if (service.binary == 'nova-compute' and
+                                 service.status == 'disabled')]
         disabled_service = disabled_services[0]
 
         self.mock_migrate_host.side_effect = self.exceptions.nova
diff --git a/openstack_dashboard/dashboards/admin/images/views.py b/openstack_dashboard/dashboards/admin/images/views.py
index 2f9a733542..a4b9029714 100644
--- a/openstack_dashboard/dashboards/admin/images/views.py
+++ b/openstack_dashboard/dashboards/admin/images/views.py
@@ -124,8 +124,8 @@ class IndexView(tables.DataTableView):
                 invalid_msg = ('API query is not valid and is ignored: '
                                '%(field)s=%(string)s')
                 try:
-                    filter_string = builtins.int(float(filter_string)
-                                                 * (units.Mi))
+                    filter_string = builtins.int(float(filter_string) *
+                                                 (units.Mi))
                     if filter_string >= 0:
                         filters[filter_field] = filter_string
                     else:
diff --git a/openstack_dashboard/dashboards/admin/instances/tables.py b/openstack_dashboard/dashboards/admin/instances/tables.py
index 85efeadc4a..668703276a 100644
--- a/openstack_dashboard/dashboards/admin/instances/tables.py
+++ b/openstack_dashboard/dashboards/admin/instances/tables.py
@@ -66,9 +66,9 @@ class MigrateInstance(policy.PolicyTargetMixin, tables.BatchAction):
         )
 
     def allowed(self, request, instance):
-        return ((instance.status in project_tables.ACTIVE_STATES
-                 or instance.status == 'SHUTOFF')
-                and not project_tables.is_deleting(instance))
+        return ((instance.status in project_tables.ACTIVE_STATES or
+                 instance.status == 'SHUTOFF') and
+                not project_tables.is_deleting(instance))
 
     def action(self, request, obj_id):
         api.nova.server_migrate(request, obj_id)
@@ -84,8 +84,8 @@ class LiveMigrateInstance(policy.PolicyTargetMixin,
         ("compute", "os_compute_api:os-migrate-server:migrate_live"),)
 
     def allowed(self, request, instance):
-        return ((instance.status in project_tables.ACTIVE_STATES)
-                and not project_tables.is_deleting(instance))
+        return (instance.status in project_tables.ACTIVE_STATES and
+                not project_tables.is_deleting(instance))
 
 
 class AdminUpdateRow(project_tables.UpdateRow):
diff --git a/openstack_dashboard/dashboards/admin/networks/ports/workflows.py b/openstack_dashboard/dashboards/admin/networks/ports/workflows.py
index 269184d9b0..f6f5c056d3 100644
--- a/openstack_dashboard/dashboards/admin/networks/ports/workflows.py
+++ b/openstack_dashboard/dashboards/admin/networks/ports/workflows.py
@@ -44,8 +44,8 @@ class CreatePortInfoAction(project_workflow.CreatePortInfoAction):
 class CreatePortInfo(project_workflow.CreatePortInfo):
     action_class = CreatePortInfoAction
     depends_on = ("network_id", "target_tenant_id")
-    contributes = (project_workflow.CreatePortInfo.contributes
-                   + ['binding__host_id'])
+    contributes = (project_workflow.CreatePortInfo.contributes +
+                   ['binding__host_id'])
 
 
 class CreatePort(project_workflow.CreatePort):
diff --git a/openstack_dashboard/dashboards/admin/trunks/panel.py b/openstack_dashboard/dashboards/admin/trunks/panel.py
index a5d375b54e..6005ca5205 100644
--- a/openstack_dashboard/dashboards/admin/trunks/panel.py
+++ b/openstack_dashboard/dashboards/admin/trunks/panel.py
@@ -33,10 +33,10 @@ class Trunks(horizon.Panel):
         request = context['request']
         try:
             return (
-                super(Trunks, self).allowed(context)
-                and request.user.has_perms(self.permissions)
-                and neutron.is_extension_supported(request,
-                                                   extension_alias='trunk')
+                super(Trunks, self).allowed(context) and
+                request.user.has_perms(self.permissions) and
+                neutron.is_extension_supported(request,
+                                               extension_alias='trunk')
             )
         except Exception:
             LOG.error("Call to list enabled services failed. This is likely "
diff --git a/openstack_dashboard/dashboards/identity/groups/tables.py b/openstack_dashboard/dashboards/identity/groups/tables.py
index 1e28c13e1a..5899afeb85 100644
--- a/openstack_dashboard/dashboards/identity/groups/tables.py
+++ b/openstack_dashboard/dashboards/identity/groups/tables.py
@@ -123,8 +123,8 @@ class UserFilterAction(tables.FilterAction):
         """Naive case-insensitive search."""
         q = filter_string.lower()
         return [user for user in users
-                if q in user.name.lower()
-                or q in (getattr(user, 'email', None) or '').lower()]
+                if (q in user.name.lower() or
+                    q in (getattr(user, 'email', None) or '').lower())]
 
 
 class RemoveMembers(tables.DeleteAction):
diff --git a/openstack_dashboard/dashboards/project/images/images/tables.py b/openstack_dashboard/dashboards/project/images/images/tables.py
index b56b5f2965..4f93313022 100644
--- a/openstack_dashboard/dashboards/project/images/images/tables.py
+++ b/openstack_dashboard/dashboards/project/images/images/tables.py
@@ -157,8 +157,9 @@ class CreateVolumeFromImage(tables.LinkAction):
         return "?".join([base_url, params])
 
     def allowed(self, request, image=None):
-        if (image and image.container_format not in NOT_LAUNCHABLE_FORMATS
-                and api.cinder.is_volume_service_enabled(request)):
+        if (image and
+                image.container_format not in NOT_LAUNCHABLE_FORMATS and
+                api.cinder.is_volume_service_enabled(request)):
             return image.status == "active"
         return False
 
diff --git a/openstack_dashboard/dashboards/project/instances/tables.py b/openstack_dashboard/dashboards/project/instances/tables.py
index cc76326ee7..b457fd5b03 100644
--- a/openstack_dashboard/dashboards/project/instances/tables.py
+++ b/openstack_dashboard/dashboards/project/instances/tables.py
@@ -137,9 +137,9 @@ class RebootInstance(policy.PolicyTargetMixin, tables.BatchAction):
 
     def allowed(self, request, instance=None):
         if instance is not None:
-            return ((instance.status in ACTIVE_STATES
-                     or instance.status == 'SHUTOFF')
-                    and not is_deleting(instance))
+            return ((instance.status in ACTIVE_STATES or
+                     instance.status == 'SHUTOFF') and
+                    not is_deleting(instance))
         else:
             return True
 
@@ -230,9 +230,9 @@ class TogglePause(tables.BatchAction):
             policy_rules, request,
             target={'project_id': getattr(instance, 'tenant_id', None)})
 
-        return (has_permission
-                and (instance.status in ACTIVE_STATES or self.paused)
-                and not is_deleting(instance))
+        return (has_permission and
+                (instance.status in ACTIVE_STATES or self.paused) and
+                not is_deleting(instance))
 
     def action(self, request, obj_id):
         if self.paused:
@@ -297,9 +297,9 @@ class ToggleSuspend(tables.BatchAction):
             policy_rules, request,
             target={'project_id': getattr(instance, 'tenant_id', None)})
 
-        return (has_permission
-                and (instance.status in ACTIVE_STATES or self.suspended)
-                and not is_deleting(instance))
+        return (has_permission and
+                (instance.status in ACTIVE_STATES or self.suspended) and
+                not is_deleting(instance))
 
     def action(self, request, obj_id):
         if self.suspended:
@@ -365,9 +365,9 @@ class ToggleShelve(tables.BatchAction):
             policy_rules, request,
             target={'project_id': getattr(instance, 'tenant_id', None)})
 
-        return (has_permission
-                and (instance.status in SHELVE_READY_STATES or self.shelved)
-                and not is_deleting(instance))
+        return (has_permission and
+                (instance.status in SHELVE_READY_STATES or self.shelved) and
+                not is_deleting(instance))
 
     def action(self, request, obj_id):
         if self.shelved:
@@ -550,9 +550,9 @@ class ResizeLink(policy.PolicyTargetMixin, tables.LinkAction):
         return "?".join([base_url, param])
 
     def allowed(self, request, instance):
-        return ((instance.status in ACTIVE_STATES
-                 or instance.status == 'SHUTOFF')
-                and not is_deleting(instance))
+        return ((instance.status in ACTIVE_STATES or
+                 instance.status == 'SHUTOFF') and
+                not is_deleting(instance))
 
 
 class ConfirmResize(policy.PolicyTargetMixin, tables.Action):
@@ -590,9 +590,9 @@ class RebuildInstance(policy.PolicyTargetMixin, tables.LinkAction):
     action_type = "danger"
 
     def allowed(self, request, instance):
-        return ((instance.status in ACTIVE_STATES
-                 or instance.status == 'SHUTOFF')
-                and not is_deleting(instance))
+        return ((instance.status in ACTIVE_STATES or
+                 instance.status == 'SHUTOFF') and
+                not is_deleting(instance))
 
     def get_link_url(self, datum):
         instance_id = self.table.get_object_id(datum)
@@ -609,11 +609,11 @@ class DecryptInstancePassword(tables.LinkAction):
         enable = getattr(settings,
                          'OPENSTACK_ENABLE_PASSWORD_RETRIEVE',
                          False)
-        return (enable
-                and (instance.status in ACTIVE_STATES
-                     or instance.status == 'SHUTOFF')
-                and not is_deleting(instance)
-                and get_keyname(instance) is not None)
+        return (enable and
+                (instance.status in ACTIVE_STATES or
+                 instance.status == 'SHUTOFF') and
+                not is_deleting(instance) and
+                get_keyname(instance) is not None)
 
     def get_link_url(self, datum):
         instance_id = self.table.get_object_id(datum)
@@ -831,9 +831,9 @@ class StopInstance(policy.PolicyTargetMixin, tables.BatchAction):
         )
 
     def allowed(self, request, instance):
-        return ((instance is None)
-                or ((get_power_state(instance) in ("RUNNING", "SUSPENDED"))
-                    and not is_deleting(instance)))
+        return (instance is None or
+                (get_power_state(instance) in ("RUNNING", "SUSPENDED") and
+                 not is_deleting(instance)))
 
     def action(self, request, obj_id):
         api.nova.server_stop(request, obj_id)
@@ -918,9 +918,9 @@ class AttachVolume(tables.LinkAction):
     # is not active, or the instance is being deleted
     # or cinder is not enabled
     def allowed(self, request, instance=None):
-        return instance.status in ("ACTIVE") \
-            and not is_deleting(instance) \
-            and api.cinder.is_volume_service_enabled(request)
+        return (instance.status in ("ACTIVE") and
+                not is_deleting(instance) and
+                api.cinder.is_volume_service_enabled(request))
 
 
 class DetachVolume(AttachVolume):
@@ -933,9 +933,9 @@ class DetachVolume(AttachVolume):
     # is not active, or the instance is being deleted
     # or cinder is not enabled
     def allowed(self, request, instance=None):
-        return instance.status in ("ACTIVE") \
-            and not is_deleting(instance) \
-            and api.cinder.is_volume_service_enabled(request)
+        return (instance.status in ("ACTIVE") and
+                not is_deleting(instance) and
+                api.cinder.is_volume_service_enabled(request))
 
 
 class AttachInterface(policy.PolicyTargetMixin, tables.LinkAction):
@@ -946,10 +946,10 @@ class AttachInterface(policy.PolicyTargetMixin, tables.LinkAction):
     policy_rules = (("compute", "os_compute_api:os-attach-interfaces"),)
 
     def allowed(self, request, instance):
-        return ((instance.status in ACTIVE_STATES
-                 or instance.status == 'SHUTOFF')
-                and not is_deleting(instance)
-                and api.base.is_service_enabled(request, 'network'))
+        return ((instance.status in ACTIVE_STATES or
+                 instance.status == 'SHUTOFF') and
+                not is_deleting(instance) and
+                api.base.is_service_enabled(request, 'network'))
 
     def get_link_url(self, datum):
         instance_id = self.table.get_object_id(datum)
diff --git a/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py b/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
index bdb1cab576..b0334ab77f 100644
--- a/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
+++ b/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
@@ -519,8 +519,9 @@ class SetInstanceDetails(workflows.Step):
     def contribute(self, data, context):
         context = super(SetInstanceDetails, self).contribute(data, context)
         # Allow setting the source dynamically.
-        if ("source_type" in context and "source_id" in context
-                and context["source_type"] not in context):
+        if ("source_type" in context and
+                "source_id" in context and
+                context["source_type"] not in context):
             context[context["source_type"]] = context["source_id"]
 
         # Translate form input to context for source values.
diff --git a/openstack_dashboard/dashboards/project/network_qos/panel.py b/openstack_dashboard/dashboards/project/network_qos/panel.py
index 4c874c63c6..bac3823a5e 100644
--- a/openstack_dashboard/dashboards/project/network_qos/panel.py
+++ b/openstack_dashboard/dashboards/project/network_qos/panel.py
@@ -30,10 +30,9 @@ class NetworkQoS(horizon.Panel):
         request = context['request']
         try:
             return (
-                super(NetworkQoS, self).allowed(context)
-                and request.user.has_perms(self.permissions)
-                and neutron.is_extension_supported(request,
-                                                   extension_alias='qos')
+                super(NetworkQoS, self).allowed(context) and
+                request.user.has_perms(self.permissions) and
+                neutron.is_extension_supported(request, extension_alias='qos')
             )
         except Exception:
             LOG.error("Call to list enabled services failed. This is likely "
diff --git a/openstack_dashboard/dashboards/project/network_topology/views.py b/openstack_dashboard/dashboards/project/network_topology/views.py
index 533a592eaa..a8878c0b10 100644
--- a/openstack_dashboard/dashboards/project/network_topology/views.py
+++ b/openstack_dashboard/dashboards/project/network_topology/views.py
@@ -220,15 +220,15 @@ class JSONView(View):
     def add_resource_url(self, view, resources):
         tenant_id = self.request.user.tenant_id
         for resource in resources:
-            if (resource.get('tenant_id')
-                    and tenant_id != resource.get('tenant_id')):
+            if (resource.get('tenant_id') and
+                    tenant_id != resource.get('tenant_id')):
                 continue
             resource['url'] = reverse(view, None, [str(resource['id'])])
 
     def _check_router_external_port(self, ports, router_id, network_id):
         for port in ports:
-            if (port['network_id'] == network_id
-                    and port['device_id'] == router_id):
+            if (port['network_id'] == network_id and
+                    port['device_id'] == router_id):
                 return True
         return False
 
@@ -361,8 +361,8 @@ class JSONView(View):
                   'status': self.trans.port[port.status],
                   'original_status': port.status}
                  for port in neutron_ports
-                 if port.device_owner != 'network:router_ha_interface'
-                 and port.network_id in tenant_network_ids]
+                 if (port.device_owner != 'network:router_ha_interface' and
+                     port.network_id in tenant_network_ids)]
         self.add_resource_url('horizon:project:networks:ports:detail',
                               ports)
         return ports
diff --git a/openstack_dashboard/dashboards/project/networks/ports/views.py b/openstack_dashboard/dashboards/project/networks/ports/views.py
index 5828081577..763a4d6e1b 100644
--- a/openstack_dashboard/dashboards/project/networks/ports/views.py
+++ b/openstack_dashboard/dashboards/project/networks/ports/views.py
@@ -82,8 +82,9 @@ class DetailView(tabs.TabbedTableView):
             msg = _('Unable to retrieve port details.')
             exceptions.handle(self.request, msg, redirect=redirect)
 
-        if (api.neutron.is_extension_supported(self.request, 'mac-learning')
-                and not hasattr(port, 'mac_state')):
+        if (api.neutron.is_extension_supported(self.request,
+                                               'mac-learning') and
+                not hasattr(port, 'mac_state')):
             port.mac_state = api.neutron.OFF_STATE
 
         return port
diff --git a/openstack_dashboard/dashboards/project/networks/ports/workflows.py b/openstack_dashboard/dashboards/project/networks/ports/workflows.py
index 24371a802b..516ffdeac6 100644
--- a/openstack_dashboard/dashboards/project/networks/ports/workflows.py
+++ b/openstack_dashboard/dashboards/project/networks/ports/workflows.py
@@ -272,8 +272,8 @@ class CreatePort(workflows.Workflow):
         # If port_security_enabled is set to False, security groups on the port
         # must be cleared. We will clear the current security groups
         # in this case.
-        if ('port_security_enabled' in params
-                and not params['port_security_enabled']):
+        if ('port_security_enabled' in params and
+                not params['port_security_enabled']):
             params['security_groups'] = []
         # In case of CreatePortSecurityGroup registered, 'wanted_groups'
         # exists in context.
@@ -421,8 +421,8 @@ class UpdatePort(workflows.Workflow):
         # If port_security_enabled is set to False, security groups on the port
         # must be cleared. We will clear the current security groups
         # in this case.
-        if ('port_security_enabled' in params
-                and not params['port_security_enabled']):
+        if ('port_security_enabled' in params and
+                not params['port_security_enabled']):
             params['security_groups'] = []
         # In case of UpdatePortSecurityGroup registered, 'wanted_groups'
         # exists in data.
diff --git a/openstack_dashboard/dashboards/project/routers/extensions/extraroutes/tables.py b/openstack_dashboard/dashboards/project/routers/extensions/extraroutes/tables.py
index 0ee5c12c65..d7ee1a539a 100644
--- a/openstack_dashboard/dashboards/project/routers/extensions/extraroutes/tables.py
+++ b/openstack_dashboard/dashboards/project/routers/extensions/extraroutes/tables.py
@@ -67,8 +67,8 @@ class ExtraRoutesTable(tables.DataTable):
 
     def get_object_display(self, datum):
         """Display ExtraRoutes when deleted."""
-        return (super(ExtraRoutesTable, self).get_object_display(datum)
-                or datum.destination + " -> " + datum.nexthop)
+        return (super(ExtraRoutesTable, self).get_object_display(datum) or
+                datum.destination + " -> " + datum.nexthop)
 
     class Meta(object):
         name = "extra_routes"
diff --git a/openstack_dashboard/dashboards/project/routers/ports/forms.py b/openstack_dashboard/dashboards/project/routers/ports/forms.py
index 4a2730d306..909d837867 100644
--- a/openstack_dashboard/dashboards/project/routers/ports/forms.py
+++ b/openstack_dashboard/dashboards/project/routers/ports/forms.py
@@ -69,8 +69,8 @@ class AddInterface(forms.SelfHandlingForm):
                          '%s%s (%s)' % (net_name, subnet.cidr,
                                         subnet.name or subnet.id))
                         for subnet in n['subnets']
-                        if subnet.id not in router_subnet_ids
-                        and subnet.gateway_ip]
+                        if (subnet.id not in router_subnet_ids and
+                            subnet.gateway_ip)]
         if choices:
             choices.insert(0, ("", _("Select Subnet")))
         else:
diff --git a/openstack_dashboard/dashboards/project/security_groups/tables.py b/openstack_dashboard/dashboards/project/security_groups/tables.py
index 3872116efc..84e9c576ef 100644
--- a/openstack_dashboard/dashboards/project/security_groups/tables.py
+++ b/openstack_dashboard/dashboards/project/security_groups/tables.py
@@ -204,9 +204,9 @@ def check_rule_template(port, ip_proto):
     if not rules_dict:
         return port
     templ_rule = [rule for rule in rules_dict.values()
-                  if (str(port) == rule['from_port']
-                      and str(port) == rule['to_port']
-                      and ip_proto == rule['ip_protocol'])]
+                  if (str(port) == rule['from_port'] and
+                      str(port) == rule['to_port'] and
+                      ip_proto == rule['ip_protocol'])]
     if templ_rule:
         return u"%(from_port)s (%(name)s)" % templ_rule[0]
     return port
diff --git a/openstack_dashboard/dashboards/project/server_groups/panel.py b/openstack_dashboard/dashboards/project/server_groups/panel.py
index 557bf5fe31..12202875e0 100644
--- a/openstack_dashboard/dashboards/project/server_groups/panel.py
+++ b/openstack_dashboard/dashboards/project/server_groups/panel.py
@@ -30,8 +30,8 @@ class ServerGroups(horizon.Panel):
         request = context['request']
         try:
             return (
-                super(ServerGroups, self).allowed(context)
-                and request.user.has_perms(self.permissions)
+                super(ServerGroups, self).allowed(context) and
+                request.user.has_perms(self.permissions)
             )
         except Exception:
             LOG.exception("Call to list enabled services failed. This is "
diff --git a/openstack_dashboard/dashboards/project/trunks/panel.py b/openstack_dashboard/dashboards/project/trunks/panel.py
index a37b178023..f7f51d302e 100644
--- a/openstack_dashboard/dashboards/project/trunks/panel.py
+++ b/openstack_dashboard/dashboards/project/trunks/panel.py
@@ -32,10 +32,10 @@ class Trunks(horizon.Panel):
         request = context['request']
         try:
             return (
-                super(Trunks, self).allowed(context)
-                and request.user.has_perms(self.permissions)
-                and neutron.is_extension_supported(request,
-                                                   extension_alias='trunk')
+                super(Trunks, self).allowed(context) and
+                request.user.has_perms(self.permissions) and
+                neutron.is_extension_supported(request,
+                                               extension_alias='trunk')
             )
         except Exception:
             LOG.error("Call to list enabled services failed. This is likely "
diff --git a/openstack_dashboard/dashboards/project/volumes/tables.py b/openstack_dashboard/dashboards/project/volumes/tables.py
index ecadc06411..8b33ef5190 100644
--- a/openstack_dashboard/dashboards/project/volumes/tables.py
+++ b/openstack_dashboard/dashboards/project/volumes/tables.py
@@ -141,10 +141,10 @@ class CreateVolume(tables.LinkAction):
     def allowed(self, request, volume=None):
         limits = api.cinder.tenant_absolute_limits(request)
 
-        gb_available = (limits.get('maxTotalVolumeGigabytes', float("inf"))
-                        - limits.get('totalGigabytesUsed', 0))
-        volumes_available = (limits.get('maxTotalVolumes', float("inf"))
-                             - limits.get('totalVolumesUsed', 0))
+        gb_available = (limits.get('maxTotalVolumeGigabytes', float("inf")) -
+                        limits.get('totalGigabytesUsed', 0))
+        volumes_available = (limits.get('maxTotalVolumes', float("inf")) -
+                             limits.get('totalVolumesUsed', 0))
 
         if gb_available <= 0 or volumes_available <= 0:
             if "disabled" not in self.classes:
@@ -217,8 +217,8 @@ class CreateSnapshot(VolumePolicyTargetMixin, tables.LinkAction):
             exceptions.handle(request, _('Unable to retrieve tenant limits.'))
             limits = {}
 
-        snapshots_available = (limits.get('maxTotalSnapshots', float("inf"))
-                               - limits.get('totalSnapshotsUsed', 0))
+        snapshots_available = (limits.get('maxTotalSnapshots', float("inf")) -
+                               limits.get('totalSnapshotsUsed', 0))
 
         if snapshots_available <= 0 and "disabled" not in self.classes:
             self.classes = [c for c in self.classes] + ['disabled']
diff --git a/openstack_dashboard/dashboards/project/volumes/views.py b/openstack_dashboard/dashboards/project/volumes/views.py
index 3bf3c2d62a..a5706b5669 100644
--- a/openstack_dashboard/dashboards/project/volumes/views.py
+++ b/openstack_dashboard/dashboards/project/volumes/views.py
@@ -280,8 +280,8 @@ class ExtendView(forms.ModalFormView):
         context['submit_url'] = reverse(self.submit_url, args=args)
         try:
             usages = quotas.tenant_limit_usages(self.request)
-            usages['totalGigabytesUsed'] = (usages['totalGigabytesUsed']
-                                            - context['volume'].size)
+            usages['totalGigabytesUsed'] = (usages['totalGigabytesUsed'] -
+                                            context['volume'].size)
             context['usages'] = usages
         except Exception:
             exceptions.handle(self.request)
diff --git a/openstack_dashboard/test/integration_tests/pages/project/compute/access_and_security/apiaccesspage.py b/openstack_dashboard/test/integration_tests/pages/project/compute/access_and_security/apiaccesspage.py
index be40fc609e..95b6de4aa4 100644
--- a/openstack_dashboard/test/integration_tests/pages/project/compute/access_and_security/apiaccesspage.py
+++ b/openstack_dashboard/test/integration_tests/pages/project/compute/access_and_security/apiaccesspage.py
@@ -48,8 +48,9 @@ class ApiaccessPage(basepage.BaseNavigationPage):
             self.apiaccess_table.download_openstack_rc_v3()
 
     def list_of_files(self, directory, template):
-        return [f for f in listdir(directory) if isfile(join(directory, f))
-                and f.endswith(template)]
+        return [f for f in listdir(directory)
+                if (isfile(join(directory, f)) and
+                    f.endswith(template))]
 
     def get_credentials_from_file(self, version, directory, template):
         self._wait_until(
diff --git a/openstack_dashboard/test/integration_tests/pages/project/compute/access_and_security/floatingipspage.py b/openstack_dashboard/test/integration_tests/pages/project/compute/access_and_security/floatingipspage.py
index 33d3770a68..9de2514732 100644
--- a/openstack_dashboard/test/integration_tests/pages/project/compute/access_and_security/floatingipspage.py
+++ b/openstack_dashboard/test/integration_tests/pages/project/compute/access_and_security/floatingipspage.py
@@ -72,7 +72,7 @@ class FloatingipsPage(basepage.BaseNavigationPage):
         floatingip_form = self.floatingips_table.allocate_ip()
         floatingip_form.submit()
         ip = re.compile('(([2][5][0-5]\.)|([2][0-4][0-9]\.)'
-                        + '|([0-1]?[0-9]?[0-9]\.)){3}(([2][5][0-5])|'
+                        '|([0-1]?[0-9]?[0-9]\.)){3}(([2][5][0-5])|'
                         '([2][0-4][0-9])|([0-1]?[0-9]?[0-9]))')
         match = ip.search((self._get_element(
             *self._floatingips_fadein_popup_locator)).text)
diff --git a/openstack_dashboard/test/unit/api/rest/test_neutron.py b/openstack_dashboard/test/unit/api/rest/test_neutron.py
index c182577227..ddad61a5b9 100644
--- a/openstack_dashboard/test/unit/api/rest/test_neutron.py
+++ b/openstack_dashboard/test/unit/api/rest/test_neutron.py
@@ -62,8 +62,7 @@ class NeutronNetworksTestCase(test.TestCase):
         response = neutron.Networks().post(request)
         self.assertStatusCode(response, 201)
         self.assertEqual(response['location'],
-                         '/api/neutron/networks/'
-                         + self.networks.first().id)
+                         '/api/neutron/networks/' + self.networks.first().id)
         exp_resp = self._dictify_network(self.networks.first())
         self.assertEqual(response.json, exp_resp)
         mock_network_create.assert_called_once_with(request, **expected)
diff --git a/openstack_dashboard/test/unit/api/test_neutron.py b/openstack_dashboard/test/unit/api/test_neutron.py
index 5c1526bfaf..17ccf30c34 100644
--- a/openstack_dashboard/test/unit/api/test_neutron.py
+++ b/openstack_dashboard/test/unit/api/test_neutron.py
@@ -457,9 +457,9 @@ class NeutronApiTests(test.APIMockTestCase):
             expected_parent_port_ids.add(trunk['port_id'])
             expected_subport_ids |= set([p['port_id'] for p
                                          in trunk['sub_ports']])
-        expected_normal_port_ids = ({p['id'] for p in ports}
-                                    - expected_parent_port_ids
-                                    - expected_subport_ids)
+        expected_normal_port_ids = ({p['id'] for p in ports} -
+                                    expected_parent_port_ids -
+                                    expected_subport_ids)
 
         ret_val = api.neutron.port_list_with_trunk_types(self.request)
 
@@ -469,8 +469,8 @@ class NeutronApiTests(test.APIMockTestCase):
                            if isinstance(p, api.neutron.PortTrunkParent)}
         subport_ids = {p.id for p in ret_val
                        if isinstance(p, api.neutron.PortTrunkSubport)}
-        normal_port_ids = ({p.id for p in ret_val}
-                           - parent_port_ids - subport_ids)
+        normal_port_ids = ({p.id for p in ret_val} -
+                           parent_port_ids - subport_ids)
         self.assertEqual(expected_parent_port_ids, parent_port_ids)
         self.assertEqual(expected_subport_ids, subport_ids)
         self.assertEqual(expected_normal_port_ids, normal_port_ids)
diff --git a/openstack_dashboard/utils/settings.py b/openstack_dashboard/utils/settings.py
index 4100bc54c0..11176fe14d 100644
--- a/openstack_dashboard/utils/settings.py
+++ b/openstack_dashboard/utils/settings.py
@@ -46,9 +46,9 @@ def import_dashboard_config(modules):
             if hasattr(submodule, 'DASHBOARD'):
                 dashboard = submodule.DASHBOARD
                 config[dashboard].update(submodule.__dict__)
-            elif (hasattr(submodule, 'PANEL')
-                  or hasattr(submodule, 'PANEL_GROUP')
-                  or hasattr(submodule, 'FEATURE')):
+            elif (hasattr(submodule, 'PANEL') or
+                  hasattr(submodule, 'PANEL_GROUP') or
+                  hasattr(submodule, 'FEATURE')):
                 # If enabled and local.enabled contains a same filename,
                 # the file loaded later (i.e., local.enabled) will be used.
                 name = submodule.__name__.rsplit('.', 1)[1]
@@ -136,8 +136,8 @@ def update_dashboards(modules, horizon_config, installed_apps):
 
         add_exceptions = config.get('ADD_EXCEPTIONS', {}).items()
         for category, exc_list in add_exceptions:
-            exceptions[category] = tuple(set(exceptions.get(category, ())
-                                             + exc_list))
+            exceptions[category] = tuple(set(exceptions.get(category, ()) +
+                                             exc_list))
 
         angular_modules.extend(config.get('ADD_ANGULAR_MODULES', []))
         # avoid pulling in dashboard javascript dependencies multiple times
diff --git a/tox.ini b/tox.ini
index 59af27020f..097aa71672 100644
--- a/tox.ini
+++ b/tox.ini
@@ -156,8 +156,7 @@ commands =
 filename = *.py,django.wsgi
 exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject,node_modules,openstack_dashboard/enabled/*
 # E402 module level import not at top of file
-# W503 line break before binary operator
-ignore = E402,W503
+ignore = E402
 # Enable the following hacking rules which are disabled by default
 # H106 Do not put vim configuration in source files.
 # H203 Use assertIs(Not)None to check for None.