Issue 19140: inspect.Signature.bind() inaccuracies - Python tracker (original) (raw)
A pair of inconsistencies I've found using Signature.bind:
(a, *args).bind(a=0, args=1) -> BoundArguments({'a': 0, 'args': 1}) Should positional arguments not be enough for bind() to reach the parameter before *args, bind() will process the *args parameter while looking for named arguments, and eventually bind the *args parameter to any named argument for it, instead of leaving that named argument for **kwargs or erroring out.
I've attached a patch that tests and fixes both issues.
I've taken the liberty of extending test_inspect.TestSignatureBind.test_signature_bind_positional_only as it already did all the setup needed but overlooked to check the condition where a defaulted positional-only parameter is left out.