From fba5eb694b0821859719b9ee4e61c36d62eeff20 Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Wed, 20 Feb 2019 11:44:20 -0500 Subject: [PATCH] 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 --- .pylintrc | 1 - neutron/cmd/pd_notify.py | 2 +- neutron/objects/port_forwarding.py | 2 +- neutron/plugins/ml2/plugin.py | 5 ++--- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.pylintrc b/.pylintrc index dd5c11f8d40..79607cf62fa 100644 --- a/.pylintrc +++ b/.pylintrc @@ -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 diff --git a/neutron/cmd/pd_notify.py b/neutron/cmd/pd_notify.py index 27481e2680b..6fd7c123b10 100644 --- a/neutron/cmd/pd_notify.py +++ b/neutron/cmd/pd_notify.py @@ -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") diff --git a/neutron/objects/port_forwarding.py b/neutron/objects/port_forwarding.py index d1137a16764..309fabb517f 100644 --- a/neutron/objects/port_forwarding.py +++ b/neutron/objects/port_forwarding.py @@ -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) diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index 272efa0f818..d0d910ca895 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -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