Verified Commit d9ec725f authored by Karel Koci's avatar Karel Koci 🤘

euci: improve exception when invalid keyword argument is passed

parent 4a110faa
Pipeline #48824 passed with stage
in 17 seconds
...@@ -84,7 +84,8 @@ class EUci(Uci): ...@@ -84,7 +84,8 @@ class EUci(Uci):
""" """
kwdiff = set(kwargs).difference({'default', 'list'}) kwdiff = set(kwargs).difference({'default', 'list'})
if kwdiff: if kwdiff:
raise TypeError("'{}' is an invalid keyword argument for this function".format(kwdiff)) raise TypeError("'{}' is an invalid keyword argument for this function"
.format(next(iter(kwdiff))))
try: try:
values = super().get(*args) values = super().get(*args)
...@@ -114,7 +115,7 @@ class EUci(Uci): ...@@ -114,7 +115,7 @@ class EUci(Uci):
# This implements handler for str and int type as well as fallback # This implements handler for str and int type as well as fallback
return str(value) return str(value)
def set(self, *args, **kwargs): def set(self, *args):
"""Set configuration value. """Set configuration value.
Up to three positional arguments specifying configuration can be Up to three positional arguments specifying configuration can be
...@@ -130,10 +131,6 @@ class EUci(Uci): ...@@ -130,10 +131,6 @@ class EUci(Uci):
ensure correct type. That is in case of boolean for example: ensure correct type. That is in case of boolean for example:
set("foo", "fee", "faa", bool(value)) set("foo", "fee", "faa", bool(value))
""" """
kwdiff = set(kwargs).difference({})
if kwdiff:
raise TypeError("'{}' is an invalid keyword argument for this function".format(kwdiff))
dtype = type(args[-1]) dtype = type(args[-1])
if dtype == tuple or dtype == list: if dtype == tuple or dtype == list:
# We consider first value as authoritative for type # We consider first value as authoritative for type
......
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