From 9661807385d8ecf1a5ee9aa446d4ad7644a54ec0 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: May 05 2020 08:42:46 +0000 Subject: Fix E711 comparison to None Related: https://pagure.io/freeipa/issue/8306 Signed-off-by: Christian Heimes Reviewed-By: Florence Blanc-Renaud --- diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py index ecf619b..cf05bb4 100644 --- a/ipaserver/install/service.py +++ b/ipaserver/install/service.py @@ -801,7 +801,7 @@ class SimpleServiceInstance(Service): def __enable(self): self.backup_state("enabled", self.is_enabled()) - if self.gensvc_name == None: + if self.gensvc_name is None: self.enable() else: self.ldap_configure(self.gensvc_name, self.fqdn, None, self.suffix) diff --git a/ipaserver/plugins/selinuxusermap.py b/ipaserver/plugins/selinuxusermap.py index 253a182..1a3afb5 100644 --- a/ipaserver/plugins/selinuxusermap.py +++ b/ipaserver/plugins/selinuxusermap.py @@ -335,8 +335,9 @@ class selinuxusermap_add(LDAPCreate): entry_attrs['ipaenabledflag'] = 'TRUE' validate_selinuxuser_inlist(ldap, entry_attrs['ipaselinuxuser']) - # hbacrule is not allowed when usercat or hostcat is set - is_to_be_set = lambda x: x in entry_attrs and entry_attrs[x] != None + def is_to_be_set(x): + """hbacrule is not allowed when usercat or hostcat is set""" + return x in entry_attrs and entry_attrs[x] is not None are_local_members_to_be_set = any(is_to_be_set(attr) for attr in ('usercategory', diff --git a/ipatests/test_util.py b/ipatests/test_util.py index d4b6250..a8e05d1 100644 --- a/ipatests/test_util.py +++ b/ipatests/test_util.py @@ -136,7 +136,7 @@ class test_Fuzzy: assert (False == self.klass()) is True assert (True == self.klass()) is True - assert (None == self.klass()) is True + assert (None == self.klass()) is True # noqa def test_assert_deepequal(pytestconfig): diff --git a/ipatests/test_xmlrpc/test_hbactest_plugin.py b/ipatests/test_xmlrpc/test_hbactest_plugin.py index 4f5afd0..74f5d49 100644 --- a/ipatests/test_xmlrpc/test_hbactest_plugin.py +++ b/ipatests/test_xmlrpc/test_hbactest_plugin.py @@ -132,9 +132,9 @@ class test_hbactest(XMLRPC_test): nodetail=True ) assert ret['value'] == True - assert ret['error'] == None - assert ret['matched'] == None - assert ret['notmatched'] == None + assert ret['error'] is None + assert ret['matched'] is None + assert ret['notmatched'] is None def test_c_hbactest_check_rules_enabled_detail(self): """ @@ -181,8 +181,8 @@ class test_hbactest(XMLRPC_test): ) assert ret['value'] == False - assert ret['matched'] == None - assert ret['notmatched'] == None + assert ret['matched'] is None + assert ret['notmatched'] is None for rule in self.rule_names: assert u'%s_1x1' % (rule) in ret['error']