You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "temp.py", line 6, in<module>
unittest.mock.create_autospec(foo)
File "/home/rdmurray/python/p33/Lib/unittest/mock.py", line 2026, in create_autospec
mock = _set_signature(mock, spec)
File "/home/rdmurray/python/p33/Lib/unittest/mock.py", line 162, in _set_signature
result = _getsignature(original, skipfirst, instance)
File "/home/rdmurray/python/p33/Lib/unittest/mock.py", line 81, in _getsignature
regargs, varargs, varkwargs, defaults = inspect.getargspec(func)
File "/home/rdmurray/python/p33/Lib/inspect.py", line 808, in getargspec
raiseValueError("Function has keyword-only arguments or annotations"ValueError: Function has keyword-only arguments or annotations, use getfullargspec() API which can support them
This is non-trivial to fix. Although inspect.getfullargspec can be used, which does support keyword only arguments, inspect.formatargspec *doesn't* support them. (mock.create_autospec uses these to rebuild a compatible signature for generated mocks.)
The easiest route to fixing would be to extend formatargspec to optionally take extra arguments for kwonlyargs and kwonlydefaults.
Hmmm... looks like formatargspec does support these features but they aren't documented. If it works out I'll update the docs for inspect.formatargspec too.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: