Author brian.shaginaw
Recipients brian.shaginaw
Date 2019-10-15.02:26:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1571106392.69.0.85003046785.issue38478@roundup.psfhosted.org>
In-reply-to
Content
>>> import inspect
>>> def foo(bar, /, **kwargs):
...   print(bar, kwargs)
...
>>> foo(1, bar=2)
1 {'bar': 2}
>>> inspect.signature(foo).bind(1, bar=2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/inspect.py", line 3025, in bind
    return self._bind(args, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/inspect.py", line 2964, in _bind
    raise TypeError(
TypeError: multiple values for argument 'bar'


Python 3.8 introduced positional-only parameters, which allow parameter names to remain available for use in **kwargs. It looks like `inspect.signature.bind` does not recognize this, and thinks the parameter is being passed twice, which causes the above TypeError.

Expected result: <BoundArguments (bar=1, kwargs={'bar': 2})>
History
Date User Action Args
2019-10-15 02:26:32brian.shaginawsetrecipients: + brian.shaginaw
2019-10-15 02:26:32brian.shaginawsetmessageid: <1571106392.69.0.85003046785.issue38478@roundup.psfhosted.org>
2019-10-15 02:26:32brian.shaginawlinkissue38478 messages
2019-10-15 02:26:32brian.shaginawcreate