Skip to content

Commit

Permalink
move last getargspec call out of the wrapper func for speed (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjz authored Apr 1, 2020
1 parent b3d1d2c commit ac817d9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion etcd3/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,11 @@ def deco(fn):
raise TypeError("check_param() requires at least one argument of at_least_one_of, at_most_one_of")
if not (isinstance(at_least_one_of, (list, tuple)) or isinstance(at_most_one_of, (list, tuple))):
raise TypeError("check_param() only accept list or tuple as parameter")
fnargs = getargspec(fn).args

@functools.wraps(fn)
def inner(*args, **kwargs):
arguments = merge_two_dicts(kwargs, dict(zip(getargspec(fn).args, args)))
arguments = merge_two_dicts(kwargs, dict(zip(fnargs, args)))
if at_least_one_of and not [arguments.get(i) for i in at_least_one_of if arguments.get(i) is not None]:
raise TypeError("{name}() requires at least one argument of {args}"
.format(name=fn.__name__, args=','.join(at_least_one_of)))
Expand Down

0 comments on commit ac817d9

Please sign in to comment.