On 25.02.2016 17:50, Martin Basti wrote:


On 25.02.2016 15:48, Martin Basti wrote:
The last pylint 1.5 patch, \o/

https://fedorahosted.org/freeipa/ticket/5615


self-NACK too broad disables


Updated patches attached.
From 3e99288583f02661ed4875e90a10491948f42564 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Thu, 25 Feb 2016 13:46:33 +0100
Subject: [PATCH] pylint: supress false positive no-member errors

pylint 1.5 prints many false positive no-member errors which are
supressed by this commit.

https://fedorahosted.org/freeipa/ticket/5615
---
 install/tools/ipactl                     | 4 ++--
 ipalib/krb_utils.py                      | 2 +-
 ipalib/plugins/batch.py                  | 9 +++++++--
 ipalib/plugins/server.py                 | 5 +++--
 ipapython/ipaldap.py                     | 2 +-
 ipapython/ipautil.py                     | 2 +-
 ipapython/nsslib.py                      | 7 +++++--
 ipaserver/install/installutils.py        | 9 +++++++--
 ipaserver/install/ipa_otptoken_import.py | 5 +++--
 ipaserver/install/server/install.py      | 3 ++-
 ipaserver/install/service.py             | 3 ++-
 ipatests/test_xmlrpc/xmlrpc_test.py      | 2 ++
 12 files changed, 36 insertions(+), 17 deletions(-)

diff --git a/install/tools/ipactl b/install/tools/ipactl
index ff5ea5a50a291da35e895d5674bdc8ea76ed48d4..d27ada56556c58c42242cf0add11ef47d4440f56 100755
--- a/install/tools/ipactl
+++ b/install/tools/ipactl
@@ -290,7 +290,7 @@ def ipa_start(options):
 
         if isinstance(e, IpactlError):
             # do not display any other error message
-            raise IpactlError(rval=e.rval)
+            raise IpactlError(rval=e.rval)  # pylint: disable=no-member
         else:
             raise IpactlError()
 
@@ -387,7 +387,7 @@ def ipa_restart(options):
             pass
         if isinstance(e, IpactlError):
             # do not display any other error message
-            raise IpactlError(rval=e.rval)
+            raise IpactlError(rval=e.rval)  # pylint: disable=no-member
         else:
             raise IpactlError()
 
diff --git a/ipalib/krb_utils.py b/ipalib/krb_utils.py
index b33e4b7c82cf08c68220531ebacca309117ad770..e6e277c7a0926187ebcde7ba08e45ebb56ad865e 100644
--- a/ipalib/krb_utils.py
+++ b/ipalib/krb_utils.py
@@ -160,7 +160,7 @@ def get_credentials(name=None, ccache_name=None):
     try:
         return gssapi.Credentials(usage='initiate', name=name, store=store)
     except gssapi.exceptions.GSSError as e:
-        if e.min_code == KRB5_FCC_NOFILE:
+        if e.min_code == KRB5_FCC_NOFILE:  # pylint: disable=no-member
             raise ValueError('"%s", ccache="%s"' % (e.message, ccache_name))
         raise
 
diff --git a/ipalib/plugins/batch.py b/ipalib/plugins/batch.py
index 626ba2835bd5387df3d49d66293284f40e4b0d42..2da7b7ca811fc67b22c43655352ace539488ce0d 100644
--- a/ipalib/plugins/batch.py
+++ b/ipalib/plugins/batch.py
@@ -114,11 +114,16 @@ class batch(Command):
                 if isinstance(e, errors.RequirementError) or \
                     isinstance(e, errors.CommandError):
                     self.info(
-                        '%s: batch: %s', context.principal, e.__class__.__name__
+                        '%s: batch: %s',
+                        context.principal,  # pylint: disable=no-member
+                        e.__class__.__name__
                     )
                 else:
                     self.info(
-                        '%s: batch: %s(%s): %s', context.principal, name, ', '.join(api.Command[name]._repr_iter(**params)),  e.__class__.__name__
+                        '%s: batch: %s(%s): %s',
+                        context.principal, name,  # pylint: disable=no-member
+                        ', '.join(api.Command[name]._repr_iter(**params)),
+                        e.__class__.__name__
                     )
                 if isinstance(e, errors.PublicError):
                     reported_error = e
diff --git a/ipalib/plugins/server.py b/ipalib/plugins/server.py
index e31def77cc649e6392ea8527040e61a56a83ff2f..93ced8b73049b61fe274c15d84150a892cd34529 100644
--- a/ipalib/plugins/server.py
+++ b/ipalib/plugins/server.py
@@ -228,8 +228,9 @@ class server_conncheck(crud.PKQuery):
         privilege = u'Replication Administrators'
         privilege_dn = self.api.Object.privilege.get_dn(privilege)
         ldap = self.obj.backend
-        filter = ldap.make_filter(
-            {'krbprincipalname': context.principal, 'memberof': privilege_dn},
+        filter = ldap.make_filter({
+            'krbprincipalname': context.principal,  # pylint: disable=no-member
+            'memberof': privilege_dn},
             rules=ldap.MATCH_ALL)
         try:
             ldap.find_entries(base_dn=self.api.env.basedn, filter=filter)
diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py
index 7522c504b5b8901002776521f05f4ebab8c35ec8..2965ba4a5509eb16589bc9dde9485147d9114032 100644
--- a/ipapython/ipaldap.py
+++ b/ipapython/ipaldap.py
@@ -208,7 +208,7 @@ class LDAPEntry(collections.MutableMapping):
 
         Keyword arguments can be used to override values of specific attributes.
         """
-        super(LDAPEntry, self).__init__()
+        super(LDAPEntry, self).__init__()  # pylint: disable=no-member
 
         if isinstance(_conn, LDAPEntry):
             assert _dn is None
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index 2c0f5e4086bb3c7a064b879e1d3d502265d3fade..a8227ef68cc961433d770e35084061a8e949784e 100644
--- a/ipapython/ipautil.py
+++ b/ipapython/ipautil.py
@@ -1441,7 +1441,7 @@ def kinit_keytab(principal, keytab, ccache_name, config=None, attempts=1):
                               % (attempt, attempts))
             return cred
         except gssapi.exceptions.GSSError as e:
-            if e.min_code not in errors_to_retry:
+            if e.min_code not in errors_to_retry:  # pylint: disable=no-member
                 raise
             root_logger.debug("Attempt %d/%d: failed: %s"
                               % (attempt, attempts, e))
diff --git a/ipapython/nsslib.py b/ipapython/nsslib.py
index ff4c02328c0bc1d12548c99c289935acb6b82ed9..16aa1d9a4a89f214d2ae3ff06a7178be52309f44 100644
--- a/ipapython/nsslib.py
+++ b/ipapython/nsslib.py
@@ -63,7 +63,9 @@ def auth_certificate_callback(sock, check_sig, is_server, certdb):
         # and the strerror attribute will contain a string describing the reason.
         approved_usage = cert.verify_now(certdb, check_sig, intended_usage, *pin_args)
     except Exception as e:
-        root_logger.error('cert validation failed for "%s" (%s)', cert.subject, e.strerror)
+        root_logger.error(
+            'cert validation failed for "%s" (%s)', cert.subject,
+            e.strerror)  # pylint: disable=no-member
         cert_is_valid = False
         return cert_is_valid
 
@@ -93,7 +95,8 @@ def auth_certificate_callback(sock, check_sig, is_server, certdb):
         cert_is_valid = cert.verify_hostname(hostname)
     except Exception as e:
         root_logger.error('failed verifying socket hostname "%s" matches cert subject "%s" (%s)',
-                                  hostname, cert.subject, e.strerror)
+                          hostname, cert.subject,
+                          e.strerror)  # pylint: disable=no-member
         cert_is_valid = False
         return cert_is_valid
 
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
index 4489cd80b9640c33a4f8fdcf383659b80647bd25..07124265470071f89a549edaaebb01339d8f3a8d 100644
--- a/ipaserver/install/installutils.py
+++ b/ipaserver/install/installutils.py
@@ -166,7 +166,9 @@ def verify_fqdn(host_name, no_host_dns=False, local_hostname=True):
         except socket.gaierror:
             pass
         except socket.error as e:
-            root_logger.debug('socket.gethostbyaddr() error: %d: %s' % (e.errno, e.strerror))
+            root_logger.debug(
+                'socket.gethostbyaddr() error: %d: %s',
+                e.errno, e.strerror)  # pylint: disable=no-member
 
     if no_host_dns:
         print("Warning: skipping DNS resolution of host", host_name)
@@ -733,7 +735,10 @@ def run_script(main_function, operation_name, log_file_name=None,
         try:
             return_value = main_function()
         except BaseException as e:
-            if isinstance(e, SystemExit) and (e.code is None or e.code == 0):
+            if (
+                isinstance(e, SystemExit) and
+                (e.code is None or e.code == 0)  # pylint: disable=no-member
+            ):
                 # Not an error after all
                 root_logger.info('The %s command was successful',
                     operation_name)
diff --git a/ipaserver/install/ipa_otptoken_import.py b/ipaserver/install/ipa_otptoken_import.py
index e68abc889fe308d49c86c897c57296d96dd950fa..9e77ed33091c2192e3fdcb3ab7860adda9102236 100644
--- a/ipaserver/install/ipa_otptoken_import.py
+++ b/ipaserver/install/ipa_otptoken_import.py
@@ -500,11 +500,12 @@ class OTPTokenImport(admintool.AdminTool):
 
         # Verify a key is provided if one is needed.
         if self.doc.keyname is not None:
-            if self.safe_options.keyfile is None:
+            if self.safe_options.keyfile is None:  # pylint: disable=no-member
                 raise admintool.ScriptError("Encryption key required: %s!" % self.doc.keyname)
 
             # Load the keyfile.
-            with open(self.safe_options.keyfile) as f:
+            keyfile = self.safe_options.keyfile  # pylint: disable=no-member
+            with open(keyfile) as f:
                 self.doc.setKey(f.read())
 
     def run(self):
diff --git a/ipaserver/install/server/install.py b/ipaserver/install/server/install.py
index 362b99f320a7e83ff0427924c41f3e26a42c3226..0ab5b268d5d6404d51ed2795e34916fdb1f5989e 100644
--- a/ipaserver/install/server/install.py
+++ b/ipaserver/install/server/install.py
@@ -332,7 +332,8 @@ def check_master_deleted(api, masters, interactive):
         try:
             ipautil.kinit_keytab(host_princ, paths.KRB5_KEYTAB, ccache_path)
         except gssapi.exceptions.GSSError as e:
-            if e.min_code == KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN:
+            min_code = e.min_code  # pylint: disable=no-member
+            if min_code == KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN:
                 root_logger.debug("Host principal not found, assuming that "
                                   "master is removed from topology")
                 return True
diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py
index 3987c6069ef349da0477d94960df5b4b5d04b7ab..c25e21cb0a3575fcf851c0591d321da4f21aed26 100644
--- a/ipaserver/install/service.py
+++ b/ipaserver/install/service.py
@@ -446,7 +446,8 @@ class Service(object):
                 run_step(full_msg, method)
                 step += 1
         except BaseException as e:
-            if not (isinstance(e, SystemExit) and e.code == 0):
+            if not (isinstance(e, SystemExit) and
+                    e.code == 0):  # pylint: disable=no-member
                 # show the traceback, so it's not lost if cleanup method fails
                 root_logger.debug("%s" % traceback.format_exc())
                 self.print_msg('  [error] %s: %s' % (type(e).__name__, e))
diff --git a/ipatests/test_xmlrpc/xmlrpc_test.py b/ipatests/test_xmlrpc/xmlrpc_test.py
index 687958d690fa0833a50d80e4e82571f4900c1682..33088934199a2b9706f3953da1233b09c7e1315a 100644
--- a/ipatests/test_xmlrpc/xmlrpc_test.py
+++ b/ipatests/test_xmlrpc/xmlrpc_test.py
@@ -344,7 +344,9 @@ class Declarative(XMLRPC_test):
         # client side.  However, if we switch to using JSON-RPC for the default
         # transport, the exception is a free-form data structure (dict).
         # For now just compare the strings
+        # pylint: disable=no-member
         assert_deepequal(expected.strerror, e.strerror)
+        # pylint: enable=no-member
 
     def check_callable(self, nice, cmd, args, options, expected):
         name = expected.__class__.__name__
-- 
2.5.0

From a6b7cf7403b82d23347db8a23ced4a498c1ce266 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Thu, 25 Feb 2016 15:45:09 +0100
Subject: [PATCH] pylint: supress false positive no-member errors

pylint 1.5 prints many false positive no-member errors which are
supressed by this commit.

https://fedorahosted.org/freeipa/ticket/5615
---
 install/tools/ipactl                     | 4 ++--
 ipalib/plugins/batch.py                  | 9 +++++++--
 ipapython/ipaldap.py                     | 2 +-
 ipapython/nsslib.py                      | 7 +++++--
 ipaserver/install/installutils.py        | 9 +++++++--
 ipaserver/install/ipa_otptoken_import.py | 5 +++--
 ipaserver/install/service.py             | 3 ++-
 ipatests/test_xmlrpc/xmlrpc_test.py      | 3 ++-
 8 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/install/tools/ipactl b/install/tools/ipactl
index 60db5878cf763c158a7a7ec6991f23bd894baa7f..b8ffe538d0b3844c9f803e9e7c32aa1bfdf0d08d 100755
--- a/install/tools/ipactl
+++ b/install/tools/ipactl
@@ -288,7 +288,7 @@ def ipa_start(options):
 
         if isinstance(e, IpactlError):
             # do not display any other error message
-            raise IpactlError(rval=e.rval)
+            raise IpactlError(rval=e.rval)  # pylint: disable=no-member
         else:
             raise IpactlError()
 
@@ -385,7 +385,7 @@ def ipa_restart(options):
             pass
         if isinstance(e, IpactlError):
             # do not display any other error message
-            raise IpactlError(rval=e.rval)
+            raise IpactlError(rval=e.rval)  # pylint: disable=no-member
         else:
             raise IpactlError()
 
diff --git a/ipalib/plugins/batch.py b/ipalib/plugins/batch.py
index 2002eef887d82767a288278eb2b1f9f52e3d200d..20a849b3b921ab87f1625f7a20fe3702c9bb3cf1 100644
--- a/ipalib/plugins/batch.py
+++ b/ipalib/plugins/batch.py
@@ -110,11 +110,16 @@ class batch(Command):
                 if isinstance(e, errors.RequirementError) or \
                     isinstance(e, errors.CommandError):
                     self.info(
-                        '%s: batch: %s', context.principal, e.__class__.__name__
+                        '%s: batch: %s',
+                        context.principal,  # pylint: disable=no-member
+                        e.__class__.__name__
                     )
                 else:
                     self.info(
-                        '%s: batch: %s(%s): %s', context.principal, name, ', '.join(api.Command[name]._repr_iter(**params)),  e.__class__.__name__
+                        '%s: batch: %s(%s): %s',
+                        context.principal, name,  # pylint: disable=no-member
+                        ', '.join(api.Command[name]._repr_iter(**params)),
+                        e.__class__.__name__
                     )
                 if isinstance(e, errors.PublicError):
                     reported_error = e
diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py
index 4443db03bcee25033abf63786016a7931f7eed20..73d44ccabf055985a289030f6530026c91c412cb 100644
--- a/ipapython/ipaldap.py
+++ b/ipapython/ipaldap.py
@@ -207,7 +207,7 @@ class LDAPEntry(collections.MutableMapping):
 
         Keyword arguments can be used to override values of specific attributes.
         """
-        super(LDAPEntry, self).__init__()
+        super(LDAPEntry, self).__init__()  # pylint: disable=no-member
 
         if isinstance(_conn, LDAPEntry):
             assert _dn is None
diff --git a/ipapython/nsslib.py b/ipapython/nsslib.py
index 79b8dc5be6a26cd6136ac62a4fa49572d765a9a0..ba29e2e4fc67102eccd0ad30668df7b16b74c714 100644
--- a/ipapython/nsslib.py
+++ b/ipapython/nsslib.py
@@ -57,7 +57,9 @@ def auth_certificate_callback(sock, check_sig, is_server, certdb):
         # and the strerror attribute will contain a string describing the reason.
         approved_usage = cert.verify_now(certdb, check_sig, intended_usage, *pin_args)
     except Exception, e:
-        root_logger.error('cert validation failed for "%s" (%s)', cert.subject, e.strerror)
+        root_logger.error(
+            'cert validation failed for "%s" (%s)', cert.subject,
+            e.strerror)  # pylint: disable=no-member
         cert_is_valid = False
         return cert_is_valid
 
@@ -87,7 +89,8 @@ def auth_certificate_callback(sock, check_sig, is_server, certdb):
         cert_is_valid = cert.verify_hostname(hostname)
     except Exception, e:
         root_logger.error('failed verifying socket hostname "%s" matches cert subject "%s" (%s)',
-                                  hostname, cert.subject, e.strerror)
+                          hostname, cert.subject,
+                          e.strerror)  # pylint: disable=no-member
         cert_is_valid = False
         return cert_is_valid
 
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
index 81a025597c97b41377c35a6714bf1d3001c868cc..cf29fa9e5a59ea9e1d5bb88b11617a5e5e8955e0 100644
--- a/ipaserver/install/installutils.py
+++ b/ipaserver/install/installutils.py
@@ -158,7 +158,9 @@ def verify_fqdn(host_name, no_host_dns=False, local_hostname=True):
         except socket.gaierror:
             pass
         except socket.error, e:
-            root_logger.debug('socket.gethostbyaddr() error: %d: %s' % (e.errno, e.strerror))
+            root_logger.debug(
+                'socket.gethostbyaddr() error: %d: %s',
+                e.errno, e.strerror)  # pylint: disable=no-member
 
     if no_host_dns:
         print "Warning: skipping DNS resolution of host", host_name
@@ -731,7 +733,10 @@ def run_script(main_function, operation_name, log_file_name=None,
         try:
             return_value = main_function()
         except BaseException, e:
-            if isinstance(e, SystemExit) and (e.code is None or e.code == 0):
+            if (
+                isinstance(e, SystemExit) and
+                (e.code is None or e.code == 0)  # pylint: disable=no-member
+            ):
                 # Not an error after all
                 root_logger.info('The %s command was successful',
                     operation_name)
diff --git a/ipaserver/install/ipa_otptoken_import.py b/ipaserver/install/ipa_otptoken_import.py
index 9be44cfe677a7d33ce3ec7725e23fdbf8141190a..efe1841733c65ee728c520c0556a446cee4a64fb 100644
--- a/ipaserver/install/ipa_otptoken_import.py
+++ b/ipaserver/install/ipa_otptoken_import.py
@@ -496,11 +496,12 @@ class OTPTokenImport(admintool.AdminTool):
 
         # Verify a key is provided if one is needed.
         if self.doc.keyname is not None:
-            if self.safe_options.keyfile is None:
+            if self.safe_options.keyfile is None:  # pylint: disable=no-member
                 raise admintool.ScriptError("Encryption key required: %s!" % self.doc.keyname)
 
             # Load the keyfile.
-            with open(self.safe_options.keyfile) as f:
+            keyfile = self.safe_options.keyfile  # pylint: disable=no-member
+            with open(keyfile) as f:
                 self.doc.setKey(f.read())
 
     def run(self):
diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py
index e59e82c9fbd0c15dd97c1814a91a78612a151230..9846a37bc9730dfe88884f786558bb6a8c75d665 100644
--- a/ipaserver/install/service.py
+++ b/ipaserver/install/service.py
@@ -418,7 +418,8 @@ class Service(object):
                 run_step(full_msg, method)
                 step += 1
         except BaseException as e:
-            if not (isinstance(e, SystemExit) and e.code == 0):
+            if not (isinstance(e, SystemExit) and
+                    e.code == 0):  # pylint: disable=no-member
                 # show the traceback, so it's not lost if cleanup method fails
                 root_logger.debug("%s" % traceback.format_exc())
                 self.print_msg('  [error] %s: %s' % (type(e).__name__, e))
diff --git a/ipatests/test_xmlrpc/xmlrpc_test.py b/ipatests/test_xmlrpc/xmlrpc_test.py
index d6a0b614518f5045b88f0ac0cf4d257c9c6aed98..85587ade109eb808a1c7fe8212fc2b5fc4500586 100644
--- a/ipatests/test_xmlrpc/xmlrpc_test.py
+++ b/ipatests/test_xmlrpc/xmlrpc_test.py
@@ -343,7 +343,8 @@ class Declarative(XMLRPC_test):
         # client side.  However, if we switch to using JSON-RPC for the default
         # transport, the exception is a free-form data structure (dict).
         # For now just compare the strings
-        assert_deepequal(expected.strerror, e.strerror)
+        assert_deepequal(expected.strerror,
+                         e.strerror)  # pylint: disable=no-member
 
     def check_callable(self, nice, cmd, args, options, expected):
         name = expected.__class__.__name__
-- 
2.5.0

-- 
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

Reply via email to