Browse Source

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
changes/03/638303/4
Brian Haley 3 years ago
committed by Brian Haley
parent
commit
fba5eb694b
  1. 1
      .pylintrc
  2. 2
      neutron/cmd/pd_notify.py
  3. 2
      neutron/objects/port_forwarding.py
  4. 5
      neutron/plugins/ml2/plugin.py

1
.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

2
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")

2
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)

5
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

Loading…
Cancel
Save