URL: https://github.com/freeipa/freeipa/pull/106 Author: mbasti-rh Title: #106: Pylint: enable additional checks Action: opened
PR body: """ Enabling: * cyclic-imports * global-variable-not-assigned """ To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/106/head:pr106 git checkout pr106
From c1adc0f6765f32b3a4d11c092342f76c6b0fe9b9 Mon Sep 17 00:00:00 2001 From: Martin Basti <[email protected]> Date: Thu, 22 Sep 2016 13:46:22 +0200 Subject: [PATCH 1/2] Pylint: enable cyclic-import check It looks that pylint stopped printing false positive errors for cyclic-import check, thus check can be enabled. --- pylintrc | 1 - 1 file changed, 1 deletion(-) diff --git a/pylintrc b/pylintrc index 70cf124..28857b8 100644 --- a/pylintrc +++ b/pylintrc @@ -17,7 +17,6 @@ enable= disable= I, - cyclic-import, duplicate-code, import-error, interface-not-implemented, From 2a3c35e8c007c45351c5c84fae808e7d5ad0ff75 Mon Sep 17 00:00:00 2001 From: Martin Basti <[email protected]> Date: Thu, 22 Sep 2016 14:39:16 +0200 Subject: [PATCH 2/2] Pylint: enable global-variable-not-assigned check the global keyword should be used only when variable from outside is assigned inside, otherwise it has no effect and just confuses developers --- daemons/dnssec/ipa-dnskeysyncd | 4 +++- install/tools/ipa-replica-conncheck | 1 - ipaserver/install/dns.py | 3 --- ipaserver/install/sysupgrade.py | 3 --- ipatests/test_xmlrpc/test_cert_plugin.py | 6 ------ pylintrc | 1 - 6 files changed, 3 insertions(+), 15 deletions(-) diff --git a/daemons/dnssec/ipa-dnskeysyncd b/daemons/dnssec/ipa-dnskeysyncd index a381c29..dfe4cb4 100755 --- a/daemons/dnssec/ipa-dnskeysyncd +++ b/daemons/dnssec/ipa-dnskeysyncd @@ -38,7 +38,9 @@ KEYTAB_FB = paths.IPA_DNSKEYSYNCD_KEYTAB # Shutdown handler def commenceShutdown(signum, stack): # Declare the needed global variables - global watcher_running, ldap_connection, log + global watcher_running + global ldap_connection # pylint: disable=global-variable-not-assigned + log.info('Signal %s received: Shutting down!', signum) # We are no longer running diff --git a/install/tools/ipa-replica-conncheck b/install/tools/ipa-replica-conncheck index a192bbf..0c583cf 100755 --- a/install/tools/ipa-replica-conncheck +++ b/install/tools/ipa-replica-conncheck @@ -385,7 +385,6 @@ def main(): print_info("\nConnection from replica to master is OK.") # create listeners - global RESPONDERS print_info("Start listening on required ports for remote master check") for port in required_ports: diff --git a/ipaserver/install/dns.py b/ipaserver/install/dns.py index dedafec..912b94f 100644 --- a/ipaserver/install/dns.py +++ b/ipaserver/install/dns.py @@ -314,9 +314,6 @@ def install_check(standalone, api, replica, options, hostname): def install(standalone, replica, options, api=api): - global ip_addresses - global reverse_zones - local_dnskeysyncd_dn = DN(('cn', 'DNSKeySync'), ('cn', api.env.host), ('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc'), api.env.basedn) diff --git a/ipaserver/install/sysupgrade.py b/ipaserver/install/sysupgrade.py index 1eba38c..e9192ac 100644 --- a/ipaserver/install/sysupgrade.py +++ b/ipaserver/install/sysupgrade.py @@ -35,17 +35,14 @@ def _load_sstore(): def get_upgrade_state(module, state): _load_sstore() - global _sstore return _sstore.get_state(module, state) def set_upgrade_state(module, state, value): _load_sstore() - global _sstore _sstore.backup_state(module, state, value) def remove_upgrade_state(module, state): _load_sstore() - global _sstore _sstore.delete_state(module, state) def remove_upgrade_file(): diff --git a/ipatests/test_xmlrpc/test_cert_plugin.py b/ipatests/test_xmlrpc/test_cert_plugin.py index 2598e0b..ab09d0a 100644 --- a/ipatests/test_xmlrpc/test_cert_plugin.py +++ b/ipatests/test_xmlrpc/test_cert_plugin.py @@ -166,8 +166,6 @@ def test_0003_service_show(self): """ Verify that service-show has the right certificate using service-show. """ - global cert - res = api.Command['service_show'](self.service_princ)['result'] assert base64.b64encode(res['usercertificate'][0]) == cert @@ -175,8 +173,6 @@ def test_0004_service_find(self): """ Verify that service-find has the right certificate using service-find. """ - global cert - # Assume there is only one service res = api.Command['service_find'](self.service_princ)['result'] assert base64.b64encode(res[0]['usercertificate'][0]) == cert @@ -210,8 +206,6 @@ def test_0007_service_show(self): """ Verify the new certificate with service-show. """ - global cert, newcert - res = api.Command['service_show'](self.service_princ)['result'] # Both the old and the new certs should be listed as certificates now diff --git a/pylintrc b/pylintrc index 28857b8..5f867bd 100644 --- a/pylintrc +++ b/pylintrc @@ -46,7 +46,6 @@ disable= exec-used, fixme, global-statement, - global-variable-not-assigned, no-init, pointless-string-statement, protected-access,
-- 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
