Commit fe7c59d5 authored by Guido Trotter's avatar Guido Trotter
Browse files

Fix new pylint errors



Under squeeze pylint reports the following errors:
************* Module ganeti.serializer
E1103:155:LoadSignedJson: Instance of 'False' has no 'get' member (but some types could not be inferred)
************* Module ganeti-masterd
E1103:166:ClientRqHandler.handle: Instance of 'False' has no 'get' member (but some types could not be inferred)
E1103:167:ClientRqHandler.handle: Instance of 'False' has no 'get' member (but some types could not be inferred)
************* Module gnt-instance
E1103:431:BatchCreate: Instance of 'False' has no 'keys' member (but some types could not be inferred)

For the first two cases it's actually wrong: we had checked before that
the variable on which "get" is called is actually a dict. In the third
case though such check doesn't exist, so we add it. Then we silence the
error all three times.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent edf7d66e
...@@ -163,8 +163,8 @@ class ClientRqHandler(SocketServer.BaseRequestHandler): ...@@ -163,8 +163,8 @@ class ClientRqHandler(SocketServer.BaseRequestHandler):
logging.error("wrong request received: %s", msg) logging.error("wrong request received: %s", msg)
break break
method = request.get(luxi.KEY_METHOD, None) method = request.get(luxi.KEY_METHOD, None) # pylint: disable-msg=E1103
args = request.get(luxi.KEY_ARGS, None) args = request.get(luxi.KEY_ARGS, None) # pylint: disable-msg=E1103
if method is None or args is None: if method is None or args is None:
logging.error("no method or args in request") logging.error("no method or args in request")
break break
......
...@@ -152,6 +152,7 @@ def LoadSignedJson(txt, key): ...@@ -152,6 +152,7 @@ def LoadSignedJson(txt, key):
raise errors.SignatureError('Invalid external message') raise errors.SignatureError('Invalid external message')
if callable(key): if callable(key):
# pylint: disable-msg=E1103
key_selector = signed_dict.get("key_selector", None) key_selector = signed_dict.get("key_selector", None)
hmac_key = key(key_selector) hmac_key = key(key_selector)
if not hmac_key: if not hmac_key:
......
...@@ -423,12 +423,16 @@ def BatchCreate(opts, args): ...@@ -423,12 +423,16 @@ def BatchCreate(opts, args):
ToStderr("Can't parse the instance definition file: %s" % str(err)) ToStderr("Can't parse the instance definition file: %s" % str(err))
return 1 return 1
if not isinstance(instance_data, dict):
ToStderr("The instance definition file is not in dict format.")
return 1
jex = JobExecutor(opts=opts) jex = JobExecutor(opts=opts)
# Iterate over the instances and do: # Iterate over the instances and do:
# * Populate the specs with default value # * Populate the specs with default value
# * Validate the instance specs # * Validate the instance specs
i_names = utils.NiceSort(instance_data.keys()) i_names = utils.NiceSort(instance_data.keys()) # pylint: disable-msg=E1103
for name in i_names: for name in i_names:
specs = instance_data[name] specs = instance_data[name]
specs = _PopulateWithDefaults(specs) specs = _PopulateWithDefaults(specs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment