From e11ddf13f4d75afc5ee25c9ca03019a43769108b Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Tue, 29 Dec 2009 16:05:19 +0100 Subject: [PATCH] pylint cleanups: dangerous initializers Plus a silence for a wrong "uninitialized var". Signed-off-by: Iustin Pop Reviewed-by: Olivier Tharan --- lib/confd/client.py | 2 ++ lib/objects.py | 13 +++++++------ lib/rapi/connector.py | 4 +++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/confd/client.py b/lib/confd/client.py index 674a2ca..e2d1a8b 100644 --- a/lib/confd/client.py +++ b/lib/confd/client.py @@ -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 diff --git a/lib/objects.py b/lib/objects.py index f8d94da..314606d 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -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 diff --git a/lib/rapi/connector.py b/lib/rapi/connector.py index bc9bb8c..3ef842b 100644 --- a/lib/rapi/connector.py +++ b/lib/rapi/connector.py @@ -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): -- 1.7.10.4