diff options
author | Brian Haley <bhaley@redhat.com> | 2019-02-20 11:44:20 -0500 |
---|---|---|
committer | Brian Haley <haleyb.dev@gmail.com> | 2019-02-21 21:11:34 +0000 |
commit | fba5eb694b0821859719b9ee4e61c36d62eeff20 (patch) | |
tree | 52098c941921e685ab63c5fbc3a9b468b44b0b1a | |
parent | 7e208c30140cfe06fa4f123589985e57c246223d (diff) | |
download | neutron-fba5eb694b0821859719b9ee4e61c36d62eeff20.tar.gz |
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
-rw-r--r-- | .pylintrc | 1 | ||||
-rw-r--r-- | neutron/cmd/pd_notify.py | 2 | ||||
-rw-r--r-- | neutron/objects/port_forwarding.py | 2 | ||||
-rw-r--r-- | neutron/plugins/ml2/plugin.py | 5 |
4 files changed, 4 insertions, 6 deletions
@@ -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 27481e2680..6fd7c123b1 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 d1137a1676..309fabb517 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 272efa0f81..d0d910ca89 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 |