Hacking: Fix E731
Fix: E731 do not assign a lambda expression, use a def I just marked the lambdas with noqa. Fix also other problems found by hacking in files changed. Change-Id: I4e47670f5a96e61fba617e4cb9478958f7089711
This commit is contained in:
parent
3be50ced7a
commit
27808af118
@ -82,7 +82,7 @@ def upgrade():
|
||||
|
||||
# Map string AZ names to ID's in target tables
|
||||
# pylint: disable=no-value-for-parameter
|
||||
set_az_id_in_table = lambda table, id, name: (
|
||||
set_az_id_in_table = lambda table, id, name: ( # noqa: E731
|
||||
op.execute(
|
||||
table.update().where(table.c.availability_zone == name).values(
|
||||
{'availability_zone_id': id})
|
||||
|
@ -346,9 +346,9 @@ class DbQuotaDriver(object):
|
||||
|
||||
# Filter resources
|
||||
if has_sync:
|
||||
sync_filt = lambda x: hasattr(x, 'sync')
|
||||
sync_filt = lambda x: hasattr(x, 'sync') # noqa: E731
|
||||
else:
|
||||
sync_filt = lambda x: not hasattr(x, 'sync')
|
||||
sync_filt = lambda x: not hasattr(x, 'sync') # noqa: E731
|
||||
desired = set(keys)
|
||||
sub_resources = {k: v for k, v in resources.items()
|
||||
if k in desired and sync_filt(v)}
|
||||
|
@ -52,8 +52,8 @@ glusterfs_volume_mapped_opts = [
|
||||
'parameter which matches an integer (sequence of '
|
||||
'digits) in which case the value shall be interpreted as '
|
||||
'size of the volume in GB. Examples: '
|
||||
'"manila-share-volume-\d+$", '
|
||||
'"manila-share-volume-#{size}G-\d+$"; '
|
||||
r'"manila-share-volume-\d+$", '
|
||||
r'"manila-share-volume-#{size}G-\d+$"; '
|
||||
'with matching volume names, respectively: '
|
||||
'"manila-share-volume-12", "manila-share-volume-3G-13". '
|
||||
'In latter example, the number that matches "#{size}", '
|
||||
@ -72,10 +72,10 @@ CONF.register_opts(glusterfs_volume_mapped_opts)
|
||||
# and a transformer function ('trans') for the matched
|
||||
# string value.
|
||||
# Currently we handle only #{size}.
|
||||
PATTERN_DICT = {'size': {'pattern': '(?P<size>\d+)', 'trans': int}}
|
||||
PATTERN_DICT = {'size': {'pattern': r'(?P<size>\d+)', 'trans': int}}
|
||||
USER_MANILA_SHARE = 'user.manila-share'
|
||||
USER_CLONED_FROM = 'user.manila-cloned-from'
|
||||
UUID_RE = re.compile('\A[\da-f]{8}-([\da-f]{4}-){3}[\da-f]{12}\Z', re.I)
|
||||
UUID_RE = re.compile(r'\A[\da-f]{8}-([\da-f]{4}-){3}[\da-f]{12}\Z', re.I)
|
||||
|
||||
|
||||
class GlusterfsVolumeMappedLayout(layout.GlusterfsShareLayoutBase):
|
||||
@ -276,10 +276,10 @@ class GlusterfsVolumeMappedLayout(layout.GlusterfsShareLayoutBase):
|
||||
if size and 'size' in self.volume_pattern_keys:
|
||||
# then this function is used to extract the
|
||||
# size value for a given volume from the voldict...
|
||||
get_volsize = lambda vol: voldict[vol]['size']
|
||||
get_volsize = lambda vol: voldict[vol]['size'] # noqa: E731
|
||||
else:
|
||||
# else just use a stub.
|
||||
get_volsize = lambda vol: None
|
||||
get_volsize = lambda vol: None # noqa: E731
|
||||
for vol in unused_vols:
|
||||
# For each unused volume, we extract the <size>
|
||||
# and <host> values with which it can be inserted
|
||||
|
@ -919,7 +919,7 @@ class NetAppCmodeFileStorageLibrary(object):
|
||||
def _sort_export_locations_by_preferred_paths(self, export_locations):
|
||||
"""Sort the export locations to report preferred paths first."""
|
||||
|
||||
sort_key = lambda location: location.get(
|
||||
sort_key = lambda location: location.get( # noqa: E731
|
||||
'metadata', {}).get('preferred') is not True
|
||||
|
||||
return sorted(export_locations, key=sort_key)
|
||||
|
@ -223,7 +223,7 @@ class WindowsSMBHelper(helpers.CIFSHelperBase):
|
||||
|
||||
def _subtract_access_rules(self, access_rules, subtracted_rules):
|
||||
# Account names are case insensitive on Windows.
|
||||
filter_rules = lambda rules: [
|
||||
filter_rules = lambda rules: [ # noqa: E731
|
||||
{'access_to': access_rule['access_to'].lower(),
|
||||
'access_level': access_rule['access_level'],
|
||||
'access_type': access_rule['access_type']}
|
||||
|
@ -361,9 +361,11 @@ class TestCase(base_test.BaseTestCase):
|
||||
if k not in ignored_keys}
|
||||
|
||||
def _assertEqualListsOfObjects(self, objs1, objs2, ignored_keys=None):
|
||||
obj_to_dict = lambda o: self._dict_from_object(o, ignored_keys)
|
||||
sort_key = lambda d: [d[k] for k in sorted(d)]
|
||||
conv_and_sort = lambda obj: sorted(map(obj_to_dict, obj), key=sort_key)
|
||||
obj_to_dict = lambda o: ( # noqa: E731
|
||||
self._dict_from_object(o, ignored_keys))
|
||||
sort_key = lambda d: [d[k] for k in sorted(d)] # noqa: E731
|
||||
conv_and_sort = lambda obj: ( # noqa: E731
|
||||
sorted(map(obj_to_dict, obj), key=sort_key))
|
||||
|
||||
self.assertEqual(conv_and_sort(objs1), conv_and_sort(objs2))
|
||||
|
||||
|
@ -30,7 +30,7 @@ class TestBaseFilter(test.TestCase):
|
||||
filters = [1, 2, 3, 4]
|
||||
filter_properties = {'x': 'y'}
|
||||
|
||||
side_effect = lambda value, props: value in [2, 3]
|
||||
side_effect = lambda value, props: value in [2, 3] # noqa: E731
|
||||
self.mock_object(self.filter,
|
||||
'_filter_one',
|
||||
mock.Mock(side_effect=side_effect))
|
||||
|
@ -261,7 +261,7 @@ class ShareDriverTestCase(test.TestCase):
|
||||
|
||||
def test_snapshot_support_exists(self):
|
||||
driver.CONF.set_default('driver_handles_share_servers', True)
|
||||
fake_method = lambda *args, **kwargs: None
|
||||
fake_method = lambda *args, **kwargs: None # noqa: E731
|
||||
child_methods = {
|
||||
"create_snapshot": fake_method,
|
||||
"delete_snapshot": fake_method,
|
||||
@ -292,7 +292,7 @@ class ShareDriverTestCase(test.TestCase):
|
||||
driver.CONF.set_default('driver_handles_share_servers', True)
|
||||
|
||||
common_drv_methods, child_drv_methods = [
|
||||
{method_name: lambda *args, **kwargs: None
|
||||
{method_name: lambda *args, **kwargs: None # noqa: E731
|
||||
for method_name in method_names}
|
||||
for method_names in (common_drv_meth_names,
|
||||
child_drv_meth_names)]
|
||||
@ -316,7 +316,7 @@ class ShareDriverTestCase(test.TestCase):
|
||||
)
|
||||
def test_snapshot_support_absent(self, methods):
|
||||
driver.CONF.set_default('driver_handles_share_servers', True)
|
||||
fake_method = lambda *args, **kwargs: None
|
||||
fake_method = lambda *args, **kwargs: None # noqa: E731
|
||||
child_methods = {}
|
||||
for method in methods:
|
||||
child_methods[method] = fake_method
|
||||
@ -349,7 +349,7 @@ class ShareDriverTestCase(test.TestCase):
|
||||
def test_snapshot_support_exists_and_set_explicitly(
|
||||
self, snapshots_are_supported):
|
||||
driver.CONF.set_default('driver_handles_share_servers', True)
|
||||
fake_method = lambda *args, **kwargs: None
|
||||
fake_method = lambda *args, **kwargs: None # noqa: E731
|
||||
child_methods = {
|
||||
"create_snapshot": fake_method,
|
||||
"delete_snapshot": fake_method,
|
||||
@ -368,7 +368,7 @@ class ShareDriverTestCase(test.TestCase):
|
||||
|
||||
def test_create_share_from_snapshot_support_exists(self):
|
||||
driver.CONF.set_default('driver_handles_share_servers', True)
|
||||
fake_method = lambda *args, **kwargs: None
|
||||
fake_method = lambda *args, **kwargs: None # noqa: E731
|
||||
child_methods = {
|
||||
"create_share_from_snapshot": fake_method,
|
||||
"create_snapshot": fake_method,
|
||||
@ -391,7 +391,7 @@ class ShareDriverTestCase(test.TestCase):
|
||||
)
|
||||
def test_create_share_from_snapshot_support_absent(self, methods):
|
||||
driver.CONF.set_default('driver_handles_share_servers', True)
|
||||
fake_method = lambda *args, **kwargs: None
|
||||
fake_method = lambda *args, **kwargs: None # noqa: E731
|
||||
child_methods = {}
|
||||
for method in methods:
|
||||
child_methods[method] = fake_method
|
||||
@ -427,7 +427,7 @@ class ShareDriverTestCase(test.TestCase):
|
||||
def test_create_share_from_snapshot_exists_and_set_explicitly(
|
||||
self, create_share_from_snapshot_supported):
|
||||
driver.CONF.set_default('driver_handles_share_servers', True)
|
||||
fake_method = lambda *args, **kwargs: None
|
||||
fake_method = lambda *args, **kwargs: None # noqa: E731
|
||||
child_methods = {"create_share_from_snapshot": fake_method}
|
||||
child_class_instance = type(
|
||||
"NotRedefined", (driver.ShareDriver, ), child_methods)(True)
|
||||
|
3
tox.ini
3
tox.ini
@ -134,8 +134,7 @@ commands = alembic -c manila/db/migrations/alembic.ini revision -m ""{posargs}
|
||||
# W503 line break before binary operator
|
||||
# W504 line break after binary operator
|
||||
# W605 invalid escape sequence
|
||||
# E731 do not assign a lambda expression, use a def
|
||||
ignore = E123,E402,E731,W503,W504,W605
|
||||
ignore = E123,E402,W503,W504,W605
|
||||
builtins = _
|
||||
# [H106] Don't put vim configuration in source files.
|
||||
# [H203] Use assertIs(Not)None to check for None.
|
||||
|
Loading…
x
Reference in New Issue
Block a user