[Freeipa-devel] [PATCH] 0037 make-lint fails on Fedora 16/Rawhide

Alexander Bokovoy abokovoy at redhat.com
Mon Nov 28 15:26:11 UTC 2011


On Mon, 28 Nov 2011, Alexander Bokovoy wrote:

> Hi,
> 
> Attached are fixes for ldap.LDAPObject.add_s(self, dn, modlist) uses
> which now don't pass 'make-lint' on Fedora 16/Rawhide.
> 
> -- 
> / Alexander Bokovoy

> >From dd866262c98be779a094a617975145e2fb1e0dd1 Mon Sep 17 00:00:00 2001
> From: Alexander Bokovoy <abokovoy at redhat.com>
> Date: Mon, 28 Nov 2011 14:21:17 +0200
> Subject: [PATCH] Be more explicit when passing Entry class to
>  ldap.LDAPObject.add_s()
> 
> ldap.LDAPObject.add_s(self, dn, modlist) requires two positional arguments.
> We used to pass our Entry class which implements dictionary access that gives
> proper way to pass the positional arguments, but PyLint in Fedora 16/Rawhide
> became more strict about that and can't infer dictionary interface through
> static checking.
> 
> Thus, we need to explicitly annotate dictionary passing with **entry syntax.
> This has additional benefit to remind that we deal with multiple arguments here.
Self-NACK, doesn't really work this way. I'm still looking at better 
approach but intermediate solution is to use pylint hints.

Conservative patch is attached.

-- 
/ Alexander Bokovoy
-------------- next part --------------
>From 4eb6c88392f43d57943426968a98fca1a91f302c Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy <abokovoy at redhat.com>
Date: Mon, 28 Nov 2011 17:02:11 +0200
Subject: [PATCH] Disable pylint false positive when passing Entry class to
 ldap.LDAPObject.add_s()

ldap.LDAPObject.add_s(self, dn, modlist) requires two positional arguments.
We used to pass our Entry class which implements dictionary access that gives
proper way to pass the positional arguments, but PyLint in Fedora 16/Rawhide
became more strict about that and can't infer dictionary interface through
static checking.

Thus, we need to explicitly mark this error as false positive as PyLint is unable to
guess that.

This has additional benefit to remind that we deal with multiple arguments here.
---
 ipaserver/install/adtrustinstance.py |    6 +++---
 ipaserver/install/krbinstance.py     |    4 ++--
 ipaserver/install/service.py         |    2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/ipaserver/install/adtrustinstance.py b/ipaserver/install/adtrustinstance.py
index 96f99dc9b76370c07b727e8e94ccabfe7afca074..8a9e3d9375f00fef9eb7aafb0a22e88cd09d7270 100644
--- a/ipaserver/install/adtrustinstance.py
+++ b/ipaserver/install/adtrustinstance.py
@@ -99,7 +99,7 @@ class ADTRUSTInstance(service.Service):
         entry.setValues("objectclass", ["account", "simplesecurityobject"])
         entry.setValues("uid", "samba")
         entry.setValues("userPassword", self.smb_dn_pwd)
-        self.admin_conn.add_s(entry)
+        self.admin_conn.add_s(entry) #pylint: disable=E1120
 
         # And finally grant it permission to read NT passwords, we do not want
         # to support LM passwords so there is no need to allow access to them.
@@ -188,7 +188,7 @@ class ADTRUSTInstance(service.Service):
             entry = ipaldap.Entry(self.trust_dn)
             entry.setValues("objectclass", ["nsContainer"])
             entry.setValues("cn", "trusts")
-            self.admin_conn.add_s(entry)
+            self.admin_conn.add_s(entry) #pylint: disable=E1120
 
         entry = ipaldap.Entry(self.smb_dom_dn)
         entry.setValues("objectclass", ["sambaDomain", "nsContainer"])
@@ -196,7 +196,7 @@ class ADTRUSTInstance(service.Service):
         entry.setValues("sambaDomainName", self.netbios_name)
         entry.setValues("sambaSID", self.__gen_sid_string())
         #TODO: which MAY attributes do we want to set ?
-        self.admin_conn.add_s(entry)
+        self.admin_conn.add_s(entry) #pylint: disable=E1120
 
     def __write_smb_conf(self):
         self.fstore.backup_file(self.smb_conf)
diff --git a/ipaserver/install/krbinstance.py b/ipaserver/install/krbinstance.py
index 6ed38516223a56e723bcc9cf643ac2b362200da4..193dacd2b406332c83ed8b3b86cd7b3cff20471a 100644
--- a/ipaserver/install/krbinstance.py
+++ b/ipaserver/install/krbinstance.py
@@ -259,7 +259,7 @@ class KrbInstance(service.Service):
         entry.setValues("nsSaslMapFilterTemplate", '(krbPrincipalName=\\1@\\2)')
 
         try:
-            self.admin_conn.add_s(entry)
+            self.admin_conn.add_s(entry) #pylint: disable=E1120
         except ldap.ALREADY_EXISTS:
             root_logger.critical("failed to add Full Principal Sasl mapping")
             raise e
@@ -272,7 +272,7 @@ class KrbInstance(service.Service):
         entry.setValues("nsSaslMapFilterTemplate", '(krbPrincipalName=&@%s)' % self.realm)
 
         try:
-            self.admin_conn.add_s(entry)
+            self.admin_conn.add_s(entry) #pylint: disable=E1120
         except ldap.ALREADY_EXISTS:
             root_logger.critical("failed to add Name Only Sasl mapping")
             raise e
diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py
index 249727b15b6f3c879336c36d43410fc7234d9d9d..68888bc70fa2e661a01b78a0a74490c56dabfce5 100644
--- a/ipaserver/install/service.py
+++ b/ipaserver/install/service.py
@@ -289,7 +289,7 @@ class Service(object):
                         "enabledService", "startOrder " + str(order))
 
         try:
-            conn.add_s(entry)
+            conn.add_s(entry) #pylint: disable=E1120
         except ldap.ALREADY_EXISTS, e:
             root_logger.critical("failed to add %s Service startup entry" % name)
             raise e
-- 
1.7.7.3



More information about the Freeipa-devel mailing list