diff --git a/.pylintrc b/.pylintrc index c788d8ef9df..5095a59798f 100644 --- a/.pylintrc +++ b/.pylintrc @@ -57,7 +57,6 @@ disable= consider-using-enumerate, invalid-name, len-as-condition, - misplaced-comparison-constant, missing-docstring, singleton-comparison, superfluous-parens, diff --git a/neutron/agent/l3/namespaces.py b/neutron/agent/l3/namespaces.py index d36fdd53cc6..a6a95e5ea3a 100644 --- a/neutron/agent/l3/namespaces.py +++ b/neutron/agent/l3/namespaces.py @@ -45,7 +45,7 @@ def get_prefix_from_ns_name(ns_name): :returns: The prefix ending with a '-' or None if there is no '-' """ dash_index = ns_name.find('-') - if 0 <= dash_index: + if dash_index >= 0: return ns_name[:dash_index + 1] @@ -56,7 +56,7 @@ def get_id_from_ns_name(ns_name): :returns: Identifier or None if there is no - to end the prefix """ dash_index = ns_name.find('-') - if 0 <= dash_index: + if dash_index >= 0: return ns_name[dash_index + 1:] diff --git a/neutron/ipam/requests.py b/neutron/ipam/requests.py index 5152cb4b5b2..3fb81032444 100644 --- a/neutron/ipam/requests.py +++ b/neutron/ipam/requests.py @@ -68,7 +68,7 @@ class SubnetRequest(object, metaclass=abc.ABCMeta): if previous and pool.first <= previous.last: raise ValueError(_("Ranges must not overlap")) previous = pool - if 1 < len(allocation_pools): + if len(allocation_pools) > 1: # Checks that all the ranges are in the same IP version. # IPRange sorts first by ip version so we can get by with just # checking the first and the last range having sorted them diff --git a/neutron/objects/subnet.py b/neutron/objects/subnet.py index 13bd482749f..2f875430379 100644 --- a/neutron/objects/subnet.py +++ b/neutron/objects/subnet.py @@ -349,7 +349,7 @@ class Subnet(base.NeutronDbObject): segment_ids = {subnet.segment_id for subnet, mapping in results if mapping} - if 1 < len(segment_ids): + if len(segment_ids) > 1: raise segment_exc.HostConnectedToMultipleSegments( host=host, network_id=network_id) @@ -395,7 +395,7 @@ class Subnet(base.NeutronDbObject): if subnet and subnet.segment_id not in segment_ids: segment_ids.append(subnet.segment_id) - if 1 < len(segment_ids) and not allow_multiple_segments: + if len(segment_ids) > 1 and not allow_multiple_segments: raise segment_exc.FixedIpsSubnetsNotOnSameSegment() if allow_multiple_segments: diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_db_sync.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_db_sync.py index b42989b99b4..6f3047b8aeb 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_db_sync.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_db_sync.py @@ -292,7 +292,7 @@ class OvnNbSynchronizer(OvnDbSynchronizer): num_acls_to_add = len(neutron_acls) num_acls_to_remove = len(ovn_acls) + num_acls_to_remove_from_ls - if 0 != num_acls_to_add or 0 != num_acls_to_remove: + if num_acls_to_add != 0 or num_acls_to_remove != 0: LOG.warning('ACLs-to-be-added %(add)d ' 'ACLs-to-be-removed %(remove)d', {'add': num_acls_to_add, diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py index 2e34d5acac9..ef0856716d1 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py @@ -693,7 +693,7 @@ class OvnIdlDistributedLock(BaseOvnIdl): self.update_tables(tables, row.schema[0]) - if 'Chassis_Private' == self.driver.agent_chassis_table: + if self.driver.agent_chassis_table == 'Chassis_Private': if 'Chassis_Private' not in self.tables: self.driver.agent_chassis_table = 'Chassis' else: diff --git a/neutron/services/portforwarding/pf_plugin.py b/neutron/services/portforwarding/pf_plugin.py index 29a5e260149..9b964b9e2d8 100644 --- a/neutron/services/portforwarding/pf_plugin.py +++ b/neutron/services/portforwarding/pf_plugin.py @@ -556,7 +556,7 @@ class PortForwardingPlugin(fip_pf.PortForwardingPluginBase): range_b = list(map(int, str(range_b).split(':'))) invalid_port = next((port for port in (range_a + range_b) - if 65535 < port or port < 1), None) + if port > 65535 or port < 1), None) if invalid_port: raise lib_exc.BadRequest(resource=apidef.RESOURCE_NAME,