Commit 56c3598c by Őry Máté

check mandatory args if **kwargs taken too

parent 0e84e705
...@@ -369,14 +369,13 @@ class SerialLineReceiver(SerialLineReceiverBase): ...@@ -369,14 +369,13 @@ class SerialLineReceiver(SerialLineReceiverBase):
"Command %s got unexpected keyword arguments: %s" % ( "Command %s got unexpected keyword arguments: %s" % (
unicode(func), ", ".join(unexpected_kwargs))) unicode(func), ", ".join(unexpected_kwargs)))
if argspec.defaults: mandatory_args = argspec.args
mandatory_args = argspec.args[0:-len(argspec.defaults)] if argspec.defaults: # remove those with default value
else: mandatory_args = mandatory_args[0:-len(argspec.defaults)]
mandatory_args = argspec.args missing_kwargs = set(mandatory_args) - set(args)
missing_kwargs = set(mandatory_args) - set(args) if missing_kwargs:
if missing_kwargs: raise TypeError("Command %s missing arguments: %s" % (
raise TypeError("Command %s missing arguments: %s" % ( unicode(func), ", ".join(missing_kwargs)))
unicode(func), ", ".join(missing_kwargs)))
return func return func
......
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 sign in to comment