From d0818e1809a6520f42fd945cae1a69949a7e948f Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: May 05 2020 08:42:46 +0000 Subject: Fix E713 test for membership should be 'not in' Related: https://pagure.io/freeipa/issue/8306 Signed-off-by: Christian Heimes Reviewed-By: Florence Blanc-Renaud --- diff --git a/ipalib/cli.py b/ipalib/cli.py index ecd9ef2..088da83 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -1461,7 +1461,7 @@ def run(api): for klass in cli_plugins: api.add_plugin(klass) api.finalize() - if not 'config_loaded' in api.env and not 'help' in argv: + if 'config_loaded' not in api.env and 'help' not in argv: raise NotConfiguredError() sys.exit(api.Backend.cli.run(argv)) except KeyboardInterrupt: diff --git a/ipaserver/install/plugins/dns.py b/ipaserver/install/plugins/dns.py index baa19c3..ad875b4 100644 --- a/ipaserver/install/plugins/dns.py +++ b/ipaserver/install/plugins/dns.py @@ -533,7 +533,7 @@ class update_dnsserver_configuration_into_ldap(DNSUpdater): return False, [] result = self.api.Command.server_show(self.api.env.host)['result'] - if not 'DNS server' in result.get('enabled_role_servrole', []): + if 'DNS server' not in result.get('enabled_role_servrole', []): logger.debug('This server is not DNS server, nothing to upgrade') sysupgrade.set_upgrade_state('dns', 'server_config_to_ldap', True) return False, [] diff --git a/ipaserver/install/plugins/update_ldap_server_list.py b/ipaserver/install/plugins/update_ldap_server_list.py index c77a1fe..60d1994 100644 --- a/ipaserver/install/plugins/update_ldap_server_list.py +++ b/ipaserver/install/plugins/update_ldap_server_list.py @@ -24,7 +24,7 @@ class update_ldap_server_list(Updater): entry = ldap.get_entry(dn) srvlist = entry.single_value.get('defaultServerList', '') srvlist = srvlist.split() - if not self.api.env.host in srvlist: + if self.api.env.host not in srvlist: srvlist.append(self.api.env.host) attr = ' '.join(srvlist) entry['defaultServerList'] = attr diff --git a/ipaserver/install/server/replicainstall.py b/ipaserver/install/server/replicainstall.py index b22b595..52c00f1 100644 --- a/ipaserver/install/server/replicainstall.py +++ b/ipaserver/install/server/replicainstall.py @@ -742,7 +742,7 @@ def ensure_enrolled(installer): def promotion_check_ipa_domain(master_ldap_conn, basedn): entry = master_ldap_conn.get_entry(basedn, ['associatedDomain']) - if not 'associatedDomain' in entry: + if 'associatedDomain' not in entry: raise RuntimeError('IPA domain not found in LDAP.') if len(entry['associatedDomain']) > 1: diff --git a/ipaserver/plugins/aci.py b/ipaserver/plugins/aci.py index e4dc8e1..cb87074 100644 --- a/ipaserver/plugins/aci.py +++ b/ipaserver/plugins/aci.py @@ -729,7 +729,7 @@ Search for ACIs. if kw.get('attrs'): for a in acis: - if not 'targetattr' in a.target: + if 'targetattr' not in a.target: results.remove(a) continue alist1 = sorted( diff --git a/ipaserver/plugins/baseuser.py b/ipaserver/plugins/baseuser.py index 49bad9d..a0ed658 100644 --- a/ipaserver/plugins/baseuser.py +++ b/ipaserver/plugins/baseuser.py @@ -94,7 +94,7 @@ def radius_dn2pk(api, entry_attrs): entry_attrs['ipatokenradiusconfiglink'] = [pk] def convert_nsaccountlock(entry_attrs): - if not 'nsaccountlock' in entry_attrs: + if 'nsaccountlock' not in entry_attrs: entry_attrs['nsaccountlock'] = False else: nsaccountlock = Bool('temp') diff --git a/ipaserver/plugins/idrange.py b/ipaserver/plugins/idrange.py index 1658e1b..2cea8df 100644 --- a/ipaserver/plugins/idrange.py +++ b/ipaserver/plugins/idrange.py @@ -709,7 +709,7 @@ class idrange_mod(LDAPUpdate): entry_attrs['ipanttrusteddomainsid']) # Add trusted AD domain range object class, if it wasn't there - if not 'ipatrustedaddomainrange' in old_attrs['objectclass']: + if 'ipatrustedaddomainrange' not in old_attrs['objectclass']: entry_attrs['objectclass'].append('ipatrustedaddomainrange') else: diff --git a/ipaserver/plugins/schema.py b/ipaserver/plugins/schema.py index 8ac3075..96e84d2 100644 --- a/ipaserver/plugins/schema.py +++ b/ipaserver/plugins/schema.py @@ -736,7 +736,7 @@ class output(BaseParam): return obj def _retrieve(self, commandfull_name, name, **kwargs): - if not commandfull_name in self.api.Command: + if commandfull_name not in self.api.Command: raise errors.NotFound( reason=_("%(command_name)s: %(oname)s not found") % { 'command_name': commandfull_name, 'oname': self.name, @@ -754,7 +754,7 @@ class output(BaseParam): ) def _search(self, commandfull_name, **kwargs): - if not commandfull_name in self.api.Command: + if commandfull_name not in self.api.Command: return None cmd = self.api.Command[commandfull_name] diff --git a/ipaserver/plugins/service.py b/ipaserver/plugins/service.py index d64e046..6caf0fb 100644 --- a/ipaserver/plugins/service.py +++ b/ipaserver/plugins/service.py @@ -257,7 +257,7 @@ def set_certificate_attrs(entry_attrs): returns nothing """ - if not 'usercertificate' in entry_attrs: + if 'usercertificate' not in entry_attrs: return if type(entry_attrs['usercertificate']) in (list, tuple): cert = entry_attrs['usercertificate'][0] diff --git a/ipaserver/plugins/stageuser.py b/ipaserver/plugins/stageuser.py index 7434355..e56a1bb 100644 --- a/ipaserver/plugins/stageuser.py +++ b/ipaserver/plugins/stageuser.py @@ -575,7 +575,7 @@ class stageuser_activate(LDAPQuery): preserved (defined in preserved_DN_syntax_attrs) see http://www.freeipa.org/page/V3/User_Life-Cycle_Management#Adjustment_of_DN_syntax_attributes ''' - if not attr in entry_to: + if attr not in entry_to: if isinstance(entry_from[attr], (list, tuple)): # attr is multi value attribute entry_to[attr] = [] diff --git a/ipaserver/rpcserver.py b/ipaserver/rpcserver.py index 194cbbc..05c6d3e 100644 --- a/ipaserver/rpcserver.py +++ b/ipaserver/rpcserver.py @@ -341,7 +341,7 @@ class WSGIExecutioner(Executioner): command = None e = None - if not 'HTTP_REFERER' in environ: + if 'HTTP_REFERER' not in environ: return self.marshal(result, RefererError(referer='missing'), _id) if not environ['HTTP_REFERER'].startswith('https://%s/ipa' % self.api.env.host) and not self.env.in_tree: return self.marshal(result, RefererError(referer=environ['HTTP_REFERER']), _id)