mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Fix pylint 2.0 conditional-related violations
In order to support pylint 2.0 the following violations must be fixed: - `chained-comparison` (R1716): Simplify chained comparison between the operands This message is emitted when pylint encounters boolean operation like "a < b and b < c", suggesting instead to refactor it to "a < b < c". - `consider-using-in` (R1714): Consider merging these comparisons with "in" to %r To check if a variable is equal to one of many values,combine the values into a tuple and check if the variable is contained "in" it instead of checking for equality against each of the values.This is faster and less verbose. Issue: https://pagure.io/freeipa/issue/7614 Signed-off-by: Armando Neto <abiagion@redhat.com> Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
committed by
Christian Heimes
parent
f48f00c692
commit
ba954efafd
@@ -2081,7 +2081,7 @@ def install_check(options):
|
||||
rval=CLIENT_INSTALL_ERROR
|
||||
)
|
||||
|
||||
if (hostname == 'localhost') or (hostname == 'localhost.localdomain'):
|
||||
if hostname in ('localhost', 'localhost.localdomain'):
|
||||
raise ScriptError(
|
||||
"Invalid hostname, '{}' must not be used.".format(hostname),
|
||||
rval=CLIENT_INSTALL_ERROR)
|
||||
|
||||
@@ -113,10 +113,10 @@ class ACI(object):
|
||||
if token == "(":
|
||||
var = next(lexer).strip()
|
||||
operator = next(lexer)
|
||||
if operator != "=" and operator != "!=":
|
||||
if operator not in ("=", "!="):
|
||||
# Peek at the next char before giving up
|
||||
operator = operator + next(lexer)
|
||||
if operator != "=" and operator != "!=":
|
||||
if operator not in ("=", "!="):
|
||||
raise SyntaxError("No operator in target, got '%s'" % operator)
|
||||
op = operator
|
||||
val = next(lexer).strip()
|
||||
|
||||
@@ -676,7 +676,7 @@ class textui(backend.Backend):
|
||||
return -1
|
||||
try:
|
||||
selection = int(resp) - 1
|
||||
if (selection >= 0 and selection < counter):
|
||||
if (counter > selection >= 0):
|
||||
break
|
||||
except Exception:
|
||||
# fall through to the error msg
|
||||
|
||||
@@ -55,7 +55,7 @@ class Graph(object):
|
||||
|
||||
# delete edges
|
||||
self.edges = [
|
||||
e for e in self.edges if e[0] != vertex and e[1] != vertex
|
||||
e for e in self.edges if vertex not in (e[0], e[1])
|
||||
]
|
||||
|
||||
def get_tails(self, head):
|
||||
|
||||
@@ -90,7 +90,7 @@ class BINDMgr(object):
|
||||
|
||||
Change is only recorded to memory.
|
||||
self.sync() has to be called to synchronize change to BIND."""
|
||||
assert op == 'add' or op == 'del' or op == 'mod'
|
||||
assert op in ('add', 'del', 'mod')
|
||||
zone = self.dn2zone_name(attrs['dn'])
|
||||
self.modified_zones.add(zone)
|
||||
zone_keys = self.ldap_keys.setdefault(zone, {})
|
||||
|
||||
@@ -106,7 +106,7 @@ class LDAPZoneListReader(ZoneListReader):
|
||||
super(LDAPZoneListReader, self).__init__()
|
||||
|
||||
def process_ipa_zone(self, op, uuid, zone_ldap):
|
||||
assert (op == 'add' or op == 'del'), 'unsupported op %s' % op
|
||||
assert (op in ['add', 'del']), 'unsupported op %s' % op
|
||||
assert uuid is not None
|
||||
assert 'idnsname' in zone_ldap, \
|
||||
'LDAP zone UUID %s without idnsName' % uuid
|
||||
@@ -177,7 +177,7 @@ class ODSMgr(object):
|
||||
|
||||
Change is only recorded to memory.
|
||||
self.sync() have to be called to synchronize change to ODS."""
|
||||
assert op == 'add' or op == 'del'
|
||||
assert op in ('add', 'del')
|
||||
self.zl_ldap.process_ipa_zone(op, uuid, attrs)
|
||||
logger.debug("LDAP zones: %s", self.zl_ldap.mapping)
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ def verify_fqdn(host_name, no_host_dns=False, local_hostname=True):
|
||||
address = a[4][0]
|
||||
if address in verified:
|
||||
continue
|
||||
if address == '127.0.0.1' or address == '::1':
|
||||
if address in ('127.0.0.1', '::1'):
|
||||
raise HostForwardLookupError("The IPA Server hostname must not resolve to localhost (%s). A routable IP address must be used. Check /etc/hosts to see if %s is an alias for %s" % (address, host_name, address))
|
||||
try:
|
||||
logger.debug('Check reverse address of %s', address)
|
||||
|
||||
@@ -1692,7 +1692,7 @@ class cert_find(Search, CertMethod):
|
||||
self.obj._fill_owners(obj)
|
||||
|
||||
result = list(six.itervalues(result))
|
||||
if sizelimit > 0 and len(result) > sizelimit:
|
||||
if (len(result) > sizelimit > 0):
|
||||
if not truncated:
|
||||
self.add_message(messages.SearchResultTruncated(
|
||||
reason=errors.SizeLimitExceeded()))
|
||||
|
||||
@@ -339,9 +339,9 @@ def parse_and_set_boolean_xml(node, response, response_name):
|
||||
- off
|
||||
'''
|
||||
value = node.text.strip().lower()
|
||||
if value == 'true' or value == 'yes':
|
||||
if value in ('true', 'yes'):
|
||||
value = True
|
||||
elif value == 'false' or value == 'no':
|
||||
elif value in ('false', 'no'):
|
||||
value = False
|
||||
else:
|
||||
raise ValueError('expected true|false|yes|no|on|off for "%s", but got "%s"' % \
|
||||
|
||||
Reference in New Issue
Block a user