URL: https://github.com/freeipa/freeipa/pull/152 Author: martbab Title: #152: Fix warnings reported by pylint in rawhide Action: opened
PR body: """ https://fedorahosted.org/freeipa/ticket/6391 """ To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/152/head:pr152 git checkout pr152
From e3cb2e3d6f261913cfd9967f0c452a14dc38b8c1 Mon Sep 17 00:00:00 2001 From: Martin Babinsky <mbabi...@redhat.com> Date: Tue, 11 Oct 2016 17:10:50 +0200 Subject: [PATCH 1/2] remove trailing newlines form python modules pylint-1.6.4-1.fc26.noarch reports these, hence they should be fixed in order to build FreeIPA with this version https://fedorahosted.org/freeipa/ticket/6391 --- checks/check-ra.py | 1 - doc/examples/examples.py | 2 -- install/tools/ipa-otptoken-import | 1 - ipalib/request.py | 1 - ipapython/log_manager.py | 2 -- ipaserver/install/ipa_kra_install.py | 1 - ipaserver/plugins/batch.py | 1 - ipaserver/plugins/delegation.py | 1 - ipaserver/plugins/group.py | 1 - ipaserver/plugins/hbacrule.py | 1 - ipaserver/plugins/hbacsvc.py | 1 - ipaserver/plugins/hbacsvcgroup.py | 1 - ipaserver/plugins/hostgroup.py | 1 - ipaserver/plugins/idrange.py | 2 -- ipaserver/plugins/passwd.py | 1 - ipaserver/plugins/pkinit.py | 1 - ipaserver/plugins/realmdomains.py | 1 - ipaserver/plugins/role.py | 1 - ipaserver/plugins/selfservice.py | 1 - ipaserver/plugins/selinuxusermap.py | 1 - ipaserver/plugins/sudocmd.py | 1 - ipaserver/plugins/sudocmdgroup.py | 1 - ipaserver/plugins/trust.py | 1 - ipatests/test_xmlrpc/test_hbactest_plugin.py | 1 - 24 files changed, 27 deletions(-) diff --git a/checks/check-ra.py b/checks/check-ra.py index 6942804..63a53a2 100755 --- a/checks/check-ra.py +++ b/checks/check-ra.py @@ -128,4 +128,3 @@ def assert_equal(trial, reference): assert_equal(unrevoke_result, {'unrevoked' : True }) - diff --git a/doc/examples/examples.py b/doc/examples/examples.py index 3389230..35ebd82 100644 --- a/doc/examples/examples.py +++ b/doc/examples/examples.py @@ -438,5 +438,3 @@ def execute(self, *args, **options): # authors from doing all the dirty work. Let's take a look at them. # COMING SOON: baseldap.py classes, extending existing plugins, etc. - - diff --git a/install/tools/ipa-otptoken-import b/install/tools/ipa-otptoken-import index d6ae247..3309c33 100755 --- a/install/tools/ipa-otptoken-import +++ b/install/tools/ipa-otptoken-import @@ -21,4 +21,3 @@ from ipaserver.install.ipa_otptoken_import import OTPTokenImport OTPTokenImport.run_cli() - diff --git a/ipalib/request.py b/ipalib/request.py index d851ba8..5e5f019 100644 --- a/ipalib/request.py +++ b/ipalib/request.py @@ -77,4 +77,3 @@ def destroy_context(): if isinstance(value, Connection): value.disconnect() context.__dict__.clear() - diff --git a/ipapython/log_manager.py b/ipapython/log_manager.py index 0ab7a22..e24fed6 100644 --- a/ipapython/log_manager.py +++ b/ipapython/log_manager.py @@ -1556,5 +1556,3 @@ class name. All name components are dot seperated. Thus if the setattr(who, method, getattr(logger, method)) return logger - - diff --git a/ipaserver/install/ipa_kra_install.py b/ipaserver/install/ipa_kra_install.py index 9cb5f0f..8801e30 100644 --- a/ipaserver/install/ipa_kra_install.py +++ b/ipaserver/install/ipa_kra_install.py @@ -226,4 +226,3 @@ def run(self): except: self.log.error(dedent(self.FAIL_MESSAGE)) raise - diff --git a/ipaserver/plugins/batch.py b/ipaserver/plugins/batch.py index b0c89ec..7a9930b 100644 --- a/ipaserver/plugins/batch.py +++ b/ipaserver/plugins/batch.py @@ -154,4 +154,3 @@ def execute(self, methods=None, **options): ) results.append(result) return dict(count=len(results) , results=results) - diff --git a/ipaserver/plugins/delegation.py b/ipaserver/plugins/delegation.py index 28a8f30..1e9665b 100644 --- a/ipaserver/plugins/delegation.py +++ b/ipaserver/plugins/delegation.py @@ -217,4 +217,3 @@ def execute(self, aciname, **kw): result=result, value=pkey_to_value(aciname, kw), ) - diff --git a/ipaserver/plugins/group.py b/ipaserver/plugins/group.py index f48a985..67a264a 100644 --- a/ipaserver/plugins/group.py +++ b/ipaserver/plugins/group.py @@ -689,4 +689,3 @@ def execute(self, *keys, **options): result=True, value=pkey_to_value(keys[0], options), ) - diff --git a/ipaserver/plugins/hbacrule.py b/ipaserver/plugins/hbacrule.py index 7d3e485..60e5e60 100644 --- a/ipaserver/plugins/hbacrule.py +++ b/ipaserver/plugins/hbacrule.py @@ -602,4 +602,3 @@ class hbacrule_remove_service(LDAPRemoveMember): member_attributes = ['memberservice'] member_count_out = ('%i object removed.', '%i objects removed.') - diff --git a/ipaserver/plugins/hbacsvc.py b/ipaserver/plugins/hbacsvc.py index 43d6416..51f2a90 100644 --- a/ipaserver/plugins/hbacsvc.py +++ b/ipaserver/plugins/hbacsvc.py @@ -149,4 +149,3 @@ class hbacsvc_find(LDAPSearch): @register() class hbacsvc_show(LDAPRetrieve): __doc__ = _('Display information about an HBAC service.') - diff --git a/ipaserver/plugins/hbacsvcgroup.py b/ipaserver/plugins/hbacsvcgroup.py index 41157ef..f2c1894 100644 --- a/ipaserver/plugins/hbacsvcgroup.py +++ b/ipaserver/plugins/hbacsvcgroup.py @@ -173,4 +173,3 @@ class hbacsvcgroup_add_member(LDAPAddMember): @register() class hbacsvcgroup_remove_member(LDAPRemoveMember): __doc__ = _('Remove members from an HBAC service group.') - diff --git a/ipaserver/plugins/hostgroup.py b/ipaserver/plugins/hostgroup.py index dab354d..341b307 100644 --- a/ipaserver/plugins/hostgroup.py +++ b/ipaserver/plugins/hostgroup.py @@ -313,4 +313,3 @@ def post_callback(self, ldap, completed, failed, dn, entry_attrs, *keys, **optio assert isinstance(dn, DN) self.obj.suppress_netgroup_memberof(ldap, dn, entry_attrs) return (completed, dn) - diff --git a/ipaserver/plugins/idrange.py b/ipaserver/plugins/idrange.py index c94e677..5b88a6b 100644 --- a/ipaserver/plugins/idrange.py +++ b/ipaserver/plugins/idrange.py @@ -768,5 +768,3 @@ def post_callback(self, ldap, dn, entry_attrs, *keys, **options): self.obj.handle_ipabaserid(entry_attrs, options) self.obj.handle_iparangetype(entry_attrs, options) return dn - - diff --git a/ipaserver/plugins/passwd.py b/ipaserver/plugins/passwd.py index ebc41d9..8cac145 100644 --- a/ipaserver/plugins/passwd.py +++ b/ipaserver/plugins/passwd.py @@ -147,4 +147,3 @@ def execute(self, principal, password, current_password, **options): result=True, value=principal, ) - diff --git a/ipaserver/plugins/pkinit.py b/ipaserver/plugins/pkinit.py index 9aa1010..0ad4b85 100644 --- a/ipaserver/plugins/pkinit.py +++ b/ipaserver/plugins/pkinit.py @@ -102,4 +102,3 @@ def execute(self, action, **options): ldap.update_entry(entry_attrs) return dict(result=True) - diff --git a/ipaserver/plugins/realmdomains.py b/ipaserver/plugins/realmdomains.py index 3f85610..26cd5bd 100644 --- a/ipaserver/plugins/realmdomains.py +++ b/ipaserver/plugins/realmdomains.py @@ -337,4 +337,3 @@ def execute(self, *keys, **options): @register() class realmdomains_show(LDAPRetrieve): __doc__ = _('Display the list of realm domains.') - diff --git a/ipaserver/plugins/role.py b/ipaserver/plugins/role.py index f4f0c98..5d0d1f8 100644 --- a/ipaserver/plugins/role.py +++ b/ipaserver/plugins/role.py @@ -249,4 +249,3 @@ class role_remove_privilege(LDAPRemoveReverseMember): doc=_('Number of privileges removed'), ), ) - diff --git a/ipaserver/plugins/selfservice.py b/ipaserver/plugins/selfservice.py index 9009b7a..a836757 100644 --- a/ipaserver/plugins/selfservice.py +++ b/ipaserver/plugins/selfservice.py @@ -214,4 +214,3 @@ def execute(self, aciname, **kw): result=result, value=pkey_to_value(aciname, kw), ) - diff --git a/ipaserver/plugins/selinuxusermap.py b/ipaserver/plugins/selinuxusermap.py index bb48a5a..ec23153 100644 --- a/ipaserver/plugins/selinuxusermap.py +++ b/ipaserver/plugins/selinuxusermap.py @@ -566,4 +566,3 @@ class selinuxusermap_remove_host(LDAPRemoveMember): member_attributes = ['memberhost'] member_count_out = ('%i object removed.', '%i objects removed.') - diff --git a/ipaserver/plugins/sudocmd.py b/ipaserver/plugins/sudocmd.py index b198c58..a207477 100644 --- a/ipaserver/plugins/sudocmd.py +++ b/ipaserver/plugins/sudocmd.py @@ -200,4 +200,3 @@ class sudocmd_find(LDAPSearch): @register() class sudocmd_show(LDAPRetrieve): __doc__ = _('Display Sudo Command.') - diff --git a/ipaserver/plugins/sudocmdgroup.py b/ipaserver/plugins/sudocmdgroup.py index 9e8c016..58c5dc0 100644 --- a/ipaserver/plugins/sudocmdgroup.py +++ b/ipaserver/plugins/sudocmdgroup.py @@ -192,4 +192,3 @@ class sudocmdgroup_add_member(LDAPAddMember): @register() class sudocmdgroup_remove_member(LDAPRemoveMember): __doc__ = _('Remove members from Sudo Command Group.') - diff --git a/ipaserver/plugins/trust.py b/ipaserver/plugins/trust.py index c3f0cda..5326255 100644 --- a/ipaserver/plugins/trust.py +++ b/ipaserver/plugins/trust.py @@ -1863,4 +1863,3 @@ def execute(self, *keys, **options): result=True, value=pkey_to_value(keys[1], options), ) - diff --git a/ipatests/test_xmlrpc/test_hbactest_plugin.py b/ipatests/test_xmlrpc/test_hbactest_plugin.py index 12ecfc3..3809ec8 100644 --- a/ipatests/test_xmlrpc/test_hbactest_plugin.py +++ b/ipatests/test_xmlrpc/test_hbactest_plugin.py @@ -217,4 +217,3 @@ def test_g_hbactest_clear_testing_data(self): api.Command['host_del'](self.test_sourcehost) api.Command['hostgroup_del'](self.test_sourcehostgroup) api.Command['hbacsvc_del'](self.test_service) - From 39164d00c225e4dcdac4d2df58d8d2122693cfa5 Mon Sep 17 00:00:00 2001 From: Martin Babinsky <mbabi...@redhat.com> Date: Tue, 11 Oct 2016 17:35:01 +0200 Subject: [PATCH 2/2] do not use keys() method when iterating through dictionaries pylint-1.6.4-1.fc26.noarch reports "C0201(consider-iterating-dictionary)" when building FreeIPA, we have to fix these errors https://fedorahosted.org/freeipa/ticket/6391 --- client/ipa-client-install | 2 +- ipapython/dnssec/localhsm.py | 4 ++-- ipapython/ipaldap.py | 2 +- ipapython/sysrestore.py | 4 ++-- ipaserver/plugins/aci.py | 8 ++++---- ipaserver/plugins/otptoken.py | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/ipa-client-install b/client/ipa-client-install index da7d6b3..429ad4a 100755 --- a/client/ipa-client-install +++ b/client/ipa-client-install @@ -802,7 +802,7 @@ def uninstall(options, env): root_logger.error('Some files have not been restored, see %s' % paths.SYSRESTORE_INDEX) has_state = False - for module in statestore.modules.keys(): + for module in statestore.modules: root_logger.error('Some installation state for %s has not been ' 'restored, see /var/lib/ipa/sysrestore/sysrestore.state', module) diff --git a/ipapython/dnssec/localhsm.py b/ipapython/dnssec/localhsm.py index d02fc75..befe08a 100755 --- a/ipapython/dnssec/localhsm.py +++ b/ipapython/dnssec/localhsm.py @@ -166,7 +166,7 @@ def zone_privkeys(self): def import_public_key(self, source, data): params = ldap2p11helper_api_params(source) # filter out params inappropriate for public keys - for par in set(params.keys()).difference(public_key_api_params): + for par in set(params).difference(public_key_api_params): del params[par] params['data'] = data @@ -176,7 +176,7 @@ def import_public_key(self, source, data): def import_private_key(self, source, data, unwrapping_key): params = ldap2p11helper_api_params(source) # filter out params inappropriate for private keys - for par in set(params.keys()).difference(private_key_api_params): + for par in set(params).difference(private_key_api_params): del params[par] params['data'] = data params['unwrapping_key'] = unwrapping_key.handle diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py index c6f0aaa..bbaeedc 100644 --- a/ipapython/ipaldap.py +++ b/ipapython/ipaldap.py @@ -369,7 +369,7 @@ def _add_attr_name(self, name): self._names[name] = name - for oldname in self._orig.keys(): + for oldname in list(self._orig): if self._names.get(oldname) == name: self._orig[name] = self._orig.pop(oldname) break diff --git a/ipapython/sysrestore.py b/ipapython/sysrestore.py index 2a8f448..6257268 100644 --- a/ipapython/sysrestore.py +++ b/ipapython/sysrestore.py @@ -346,7 +346,7 @@ def save(self): """ root_logger.debug("Saving StateFile to '%s'", self._path) - for module in list(self.modules.keys()): + for module in list(self.modules): if len(self.modules[module]) == 0: del self.modules[module] @@ -359,7 +359,7 @@ def save(self): p = SafeConfigParser() p.optionxform = str - for module in self.modules.keys(): + for module in self.modules: p.add_section(module) for (key, value) in self.modules[module].items(): p.set(module, key, str(value)) diff --git a/ipaserver/plugins/aci.py b/ipaserver/plugins/aci.py index 6d84707..c353715 100644 --- a/ipaserver/plugins/aci.py +++ b/ipaserver/plugins/aci.py @@ -340,8 +340,8 @@ def _aci_to_kw(ldap, a, test=False, pkey_only=False): if 'target' in a.target: target = a.target['target']['expression'] found = False - for k in _type_map.keys(): - if _type_map[k] == target: + for k, value in _type_map.items(): + if value == target: kw['type'] = unicode(k) found = True break @@ -788,8 +788,8 @@ def execute(self, term=None, **kw): results.remove(a) continue found = False - for k in _type_map.keys(): - if _type_map[k] == target and kw['type'] == k: + for k, value in _type_map.items(): + if value == target and kw['type'] == k: found = True break if not found: diff --git a/ipaserver/plugins/otptoken.py b/ipaserver/plugins/otptoken.py index a1930c3..98ecbe5 100644 --- a/ipaserver/plugins/otptoken.py +++ b/ipaserver/plugins/otptoken.py @@ -114,7 +114,7 @@ def _check_interval(not_before, not_after): def _set_token_type(entry_attrs, **options): klasses = [x.lower() for x in entry_attrs.get('objectclass', [])] - for ttype in TOKEN_TYPES.keys(): + for ttype in TOKEN_TYPES: cls = 'ipatoken' + ttype if cls.lower() in klasses: entry_attrs['type'] = ttype.upper()
-- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code