From 690b5519f86545ef6705c53c16c1f3474cb0d656 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: May 05 2020 08:42:46 +0000 Subject: Fix E712 comparison to True / False Related: https://pagure.io/freeipa/issue/8306 Signed-off-by: Christian Heimes Reviewed-By: Florence Blanc-Renaud --- diff --git a/ipapython/config.py b/ipapython/config.py index 3666ac9..1f4bfe0 100644 --- a/ipapython/config.py +++ b/ipapython/config.py @@ -131,7 +131,7 @@ class IPAOptionParser(OptionParser): safe_opts_dict = {} for option, value in opts.__dict__.items(): - if all_opts_dict[option].sensitive != True: + if not all_opts_dict[option].sensitive: safe_opts_dict[option] = value return Values(safe_opts_dict) diff --git a/ipaserver/plugins/aci.py b/ipaserver/plugins/aci.py index 6de31b9..e4dc8e1 100644 --- a/ipaserver/plugins/aci.py +++ b/ipaserver/plugins/aci.py @@ -239,7 +239,7 @@ def _make_aci(ldap, current, aciname, kw): group = 'group' in kw permission = 'permission' in kw - selfaci = 'selfaci' in kw and kw['selfaci'] == True + selfaci = kw.get("selfaci", False) if group + permission + selfaci > 1: raise errors.ValidationError(name='target', error=_('group, permission and self are mutually exclusive')) elif group + permission + selfaci == 0: @@ -945,7 +945,7 @@ class aci_rename(crud.Update): # a series of keywords. Then we replace any keywords that have been # updated and convert that back into an ACI and write it out. newkw = _aci_to_kw(ldap, aci) - if 'selfaci' in newkw and newkw['selfaci'] == True: + if newkw.get("selfaci"): # selfaci is set in aci_to_kw to True only if the target is self kw['selfaci'] = True if 'aciname' in newkw: diff --git a/ipaserver/plugins/trust.py b/ipaserver/plugins/trust.py index 6fc3686..03161c4 100644 --- a/ipaserver/plugins/trust.py +++ b/ipaserver/plugins/trust.py @@ -789,7 +789,7 @@ ipa idrange-del before retrying the command with the desired range type. if (options.get('trust_type') == u'ad' and options.get('trust_secret') is None): - if options.get('bidirectional') == True: + if options.get('bidirectional'): # Bidirectional trust allows us to use cross-realm TGT, # so we can run the call under original user's credentials res = fetch_domains_from_trust(self.api, self.trustinstance, diff --git a/ipatests/test_ipapython/test_keyring.py b/ipatests/test_ipapython/test_keyring.py index ff9e5c1..1712541 100644 --- a/ipatests/test_ipapython/test_keyring.py +++ b/ipatests/test_ipapython/test_keyring.py @@ -119,13 +119,10 @@ class test_keyring: See if a key is available """ kernel_keyring.add_key(TEST_KEY, TEST_VALUE) + assert kernel_keyring.has_key(TEST_KEY) - result = kernel_keyring.has_key(TEST_KEY) - assert(result == True) kernel_keyring.del_key(TEST_KEY) - - result = kernel_keyring.has_key(TEST_KEY) - assert(result == False) + assert not kernel_keyring.has_key(TEST_KEY) def test_07(self): """ diff --git a/ipatests/test_util.py b/ipatests/test_util.py index a8e05d1..047e7ec 100644 --- a/ipatests/test_util.py +++ b/ipatests/test_util.py @@ -134,8 +134,8 @@ class test_Fuzzy: assert (self.klass(test=t, type=unicode) == b'foobar') is False assert (self.klass(test=t) == 'barfoo') is False - assert (False == self.klass()) is True - assert (True == self.klass()) is True + assert (False == self.klass()) is True # noqa + assert (True == self.klass()) is True # noqa assert (None == self.klass()) is True # noqa diff --git a/ipatests/test_xmlrpc/test_cert_plugin.py b/ipatests/test_xmlrpc/test_cert_plugin.py index 6a321de..887fc2b 100644 --- a/ipatests/test_xmlrpc/test_cert_plugin.py +++ b/ipatests/test_xmlrpc/test_cert_plugin.py @@ -240,19 +240,19 @@ class test_cert(BaseCert): from ipaserver.plugins.cert import _emails_are_valid email_addrs = [u'any@EmAiL.CoM'] result = _emails_are_valid(email_addrs, [u'any@email.com']) - assert True == result, result + assert result email_addrs = [u'any@EmAiL.CoM'] result = _emails_are_valid(email_addrs, [u'any@email.com', u'another@email.com']) - assert True == result, result + assert result result = _emails_are_valid([], [u'any@email.com']) - assert True == result, result + assert result email_addrs = [u'invalidEmailAddress'] result = _emails_are_valid(email_addrs, []) - assert False == result, result + assert not result def test_99999_cleanup(self): """ diff --git a/ipatests/test_xmlrpc/test_hbactest_plugin.py b/ipatests/test_xmlrpc/test_hbactest_plugin.py index 74f5d49..73c4ce2 100644 --- a/ipatests/test_xmlrpc/test_hbactest_plugin.py +++ b/ipatests/test_xmlrpc/test_hbactest_plugin.py @@ -115,7 +115,7 @@ class test_hbactest(XMLRPC_test): service=self.test_service, rules=self.rule_names ) - assert ret['value'] == True + assert ret['value'] assert ret['error'] is None for i in [0,1,2,3]: assert self.rule_names[i] in ret['matched'] @@ -131,7 +131,7 @@ class test_hbactest(XMLRPC_test): rules=self.rule_names, nodetail=True ) - assert ret['value'] == True + assert ret['value'] assert ret['error'] is None assert ret['matched'] is None assert ret['notmatched'] is None @@ -180,7 +180,7 @@ class test_hbactest(XMLRPC_test): nodetail=True ) - assert ret['value'] == False + assert not ret['value'] assert ret['matched'] is None assert ret['notmatched'] is None for rule in self.rule_names: