Fix pylint R1714 (consider-using-in) refactor messages

Instead of checking variables are equal to one of many
values, use a tuple and check if the variable is 'in' it.
This is faster and less verbose.

Change-Id: I429dbbd92a78fdfae3140cae8a397ff10f6d956e
This commit is contained in:
Brian Haley 2019-02-20 11:44:20 -05:00 committed by Brian Haley
parent 7e208c3014
commit fba5eb694b
4 changed files with 4 additions and 6 deletions

View File

@ -89,7 +89,6 @@ disable=
# new for python3 version of pylint
chained-comparison,
consider-using-dict-comprehension,
consider-using-in,
consider-using-set-comprehension,
unnecessary-pass,
useless-object-inheritance

View File

@ -31,7 +31,7 @@ def main():
agent_pid = sys.argv[3]
prefix = os.getenv('PREFIX1', "::")
if operation == "add" or operation == "update":
if operation in ["add", "update"]:
file_utils.replace_file(prefix_fname, "%s/64" % prefix)
elif operation == "delete":
file_utils.replace_file(prefix_fname, "::/64")

View File

@ -76,7 +76,7 @@ class PortForwarding(base.NeutronDbObject):
return True
def obj_load_attr(self, attrname):
if attrname == 'floating_ip_address' or attrname == 'router_id':
if attrname in ['floating_ip_address', 'router_id']:
return self._load_attr_from_fip(attrname)
super(PortForwarding, self).obj_load_attr(attrname)

View File

@ -2054,10 +2054,9 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
mech_context = driver_context.NetworkContext(
self, context, network_with_segments,
original_network=network_with_segments)
if (event == events.PRECOMMIT_CREATE or
event == events.PRECOMMIT_DELETE):
if event in [events.PRECOMMIT_CREATE, events.PRECOMMIT_DELETE]:
self.mechanism_manager.update_network_precommit(mech_context)
elif event == events.AFTER_CREATE or event == events.AFTER_DELETE:
elif event in [events.AFTER_CREATE, events.AFTER_DELETE]:
self.mechanism_manager.update_network_postcommit(mech_context)
@staticmethod