Fix pep8 errors

Recent pep8 upgrade and corresponding pycodestyle update break
pep8 job due to the new rules.
- E402 module level import not at top of file
- E731 do not assign a lambda expression, use a def
- W503 line break before binary operator

Change-Id: I40d386b44489e6847dd9c441b3feb56e099d252e
This commit is contained in:
Akihiro Motoki 2018-04-11 01:04:46 +09:00
parent eafc3f8b16
commit 98d261468c
5 changed files with 11 additions and 7 deletions

View File

@ -25,6 +25,8 @@
import os
import sys
from neutron_lib.version import version_info
extensions = [
'os_api_ref',
'openstackdocstheme',
@ -70,7 +72,6 @@ bug_tag = 'api-ref'
# |version| and |release|, also used in various other places throughout the
# built documents.
#
from neutron_lib.version import version_info
# The full version, including alpha/beta/rc tags.
release = version_info.release_string()
# The short X.Y version.

View File

@ -1013,8 +1013,8 @@ def validate_subports(data, valid_values=None):
if segmentation_type == 'inherit':
return
segmentation_id = subport.get("segmentation_id")
if ((not segmentation_type or segmentation_id is None)
and len(subport) > 1):
if ((not segmentation_type or segmentation_id is None) and
len(subport) > 1):
msg = _("Invalid subport details '%s': missing segmentation "
"information. Must specify both segmentation_id and "
"segmentation_type") % subport

View File

@ -104,8 +104,8 @@ class DefinitionBaseTestCase(test_base.BaseTestCase):
self.skipTest('API definition is not related to standardattr.')
def test_resource_map(self):
if (not self.resource_map and not self.subresource_map
and not self.is_shim_extension):
if (not self.resource_map and not self.subresource_map and
not self.is_shim_extension):
self.fail('Missing resource and subresource map, '
'what is this extension doing?')
elif self.is_shim_extension:

View File

@ -115,7 +115,9 @@ class CallBacksManagerTestCase(base.BaseTestCase):
[resources.PORT][events.BEFORE_CREATE][0][1]))
def test_unsubscribe_during_iteration(self):
unsub = lambda r, e, *a, **k: self.manager.unsubscribe(unsub, r, e)
def unsub(r, e, *a, **k):
return self.manager.unsubscribe(unsub, r, e)
self.manager.subscribe(unsub, resources.PORT,
events.BEFORE_CREATE)
self.manager.notify(resources.PORT, events.BEFORE_CREATE, mock.ANY)

View File

@ -17,7 +17,8 @@ from neutron_lib.tests import _base as base
class _MechanismDriver(api.MechanismDriver):
bind_port = lambda s, c: c
def bind_port(s, c):
return c
def initialize(self):
pass