summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-10-10 13:08:07 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-10-10 13:08:07 +0000
commit33d1979ff3fc0c6b0c5fc2cc1d8612f670821d8d (patch)
treeac7ba0d83e16a4d1b769998dc78f8044dcbe40c5
parente451da135ed10fc17de9e7270f245b74185d61d6 (diff)
parente0704a1f432a38cb6d59da22c042a9bab5566522 (diff)
downloadpint-33d1979ff3fc0c6b0c5fc2cc1d8612f670821d8d.tar.gz
Merge #705
705: Prevent loosing keywords r=hgrecco a=impact27 With a function as: ``` def f(a, *, b): return a+b ``` b needs to be a keyword. The wrapping is stripping the keywords and makes the function fail! Co-authored-by: Quentin Peter <impact27@users.noreply.github.com>
-rw-r--r--pint/registry_helpers.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/pint/registry_helpers.py b/pint/registry_helpers.py
index 51a0880..ed993ea 100644
--- a/pint/registry_helpers.py
+++ b/pint/registry_helpers.py
@@ -230,12 +230,12 @@ def check(ureg, *args):
updated = tuple(attr for attr in functools.WRAPPER_UPDATES if hasattr(func, attr))
@functools.wraps(func, assigned=assigned, updated=updated)
- def wrapper(*values, **kwargs):
- values, kwargs = _apply_defaults(func, values, kwargs)
- if len(dimensions) > len(values):
+ def wrapper(*args, **kwargs):
+ list_args, empty = _apply_defaults(func, args, kwargs)
+ if len(dimensions) > len(list_args):
raise TypeError("%s takes %i parameters, but %i dimensions were passed"
- % (func.__name__, len(values), len(dimensions)))
- for dim, value in zip(dimensions, values):
+ % (func.__name__, len(list_args), len(dimensions)))
+ for dim, value in zip(dimensions, list_args):
if dim is None:
continue
@@ -244,6 +244,6 @@ def check(ureg, *args):
val_dim = ureg.get_dimensionality(value)
raise DimensionalityError(value, 'a quantity of',
val_dim, dim)
- return func(*values, **kwargs)
+ return func(*args, **kwargs)
return wrapper
return decorator