dwavesystems / dwavesystems/dimod

vartype_argument decorator fails when using a keyword input named 'func'

Open
#182 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
143
Forks
91
Avg merge
1h 24m
Merged PRs (30d)
3

Description

In python 2.7.12, does not appear to be an issue in python 3

```
In [19]: @dimod.decorators.vartype_argument('vartype')
...: def f(func, vartype=dimod.BINARY):
...: pass
...:

In [20]: f(lambda a: a, vartype=dimod.SPIN)

In [21]: f(func=lambda a: a, vartype=dimod.SPIN)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
----> 1 f(func=lambda a: a, vartype=dimod.SPIN)

/home/acondello/projects/ocean/csp/venv2/local/lib/python2.7/site-packages/dimod/decorators.pyc in new_f(*args, **kwargs)
147 # (note: if call arguments don't match actual function signature,
148 # we'll fail here with the standard `TypeError`)
--> 149 bound_args = inspect.getcallargs(f, *args, **kwargs)
150
151 # `getcallargs` doesn't merge additional positional/keyword arguments,

TypeError: getcallargs() got multiple values for keyword argument 'func'
```

```
In [3]: @dimod.decorators.vartype_argument('vartype')
...: def f(a, vartype=dimod.BINARY):
...: pass
...:

In [4]: f(lambda a: a, vartype=dimod.SPIN)

In [5]: f(a=lambda a: a, vartype=dimod.SPIN)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.