pylint cleanups: dangerous initializers
authorIustin Pop <iustin@google.com>
Tue, 29 Dec 2009 15:05:19 +0000 (16:05 +0100)
committerIustin Pop <iustin@google.com>
Mon, 4 Jan 2010 09:16:29 +0000 (10:16 +0100)
Plus a silence for a wrong "uninitialized var".

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Olivier Tharan <olive@google.com>

lib/confd/client.py
lib/objects.py
lib/rapi/connector.py

index 674a2ca..e2d1a8b 100644 (file)
@@ -130,6 +130,8 @@ class ConfdClient:
     @param peers: list of peer nodes
 
     """
+    # we are actually called from init, so:
+    # pylint: disable-msg=W0201
     if not isinstance(peers, list):
       raise errors.ProgrammerError("peers must be a list")
     self._peers = peers
index f8d94da..314606d 100644 (file)
@@ -48,7 +48,7 @@ __all__ = ["ConfigObject", "ConfigData", "NIC", "Disk", "Instance",
 _TIMESTAMPS = ["ctime", "mtime"]
 _UUID = ["uuid"]
 
-def FillDict(defaults_dict, custom_dict, skip_keys=[]):
+def FillDict(defaults_dict, custom_dict, skip_keys=None):
   """Basic function to apply settings on top a default dict.
 
   @type defaults_dict: dict
@@ -63,11 +63,12 @@ def FillDict(defaults_dict, custom_dict, skip_keys=[]):
   """
   ret_dict = copy.deepcopy(defaults_dict)
   ret_dict.update(custom_dict)
-  for k in skip_keys:
-    try:
-      del ret_dict[k]
-    except KeyError:
-      pass
+  if skip_keys:
+    for k in skip_keys:
+      try:
+        del ret_dict[k]
+      except KeyError:
+        pass
   return ret_dict
 
 
index bc9bb8c..3ef842b 100644 (file)
@@ -46,12 +46,14 @@ class Mapper:
   """Map resource to method.
 
   """
-  def __init__(self, connector=CONNECTOR):
+  def __init__(self, connector=None):
     """Resource mapper constructor.
 
     @param connector: a dictionary, mapping method name with URL path regexp
 
     """
+    if connector is None:
+      connector = CONNECTOR
     self._connector = connector
 
   def getController(self, uri):