Julian Berman <julian+python....@grayvines.com> added the comment:

As a secondary behavior here, which is actually the one that matters more for 
my use case, the following seems surprising as well:

import inspect
s = inspect.signature(lambda **kwargs: kwargs).bind()
s.arguments["foo"] = 12

will similarly silently drop "foo" when attempting to call the function (i.e. 
it will not appear in bound.kwargs).

This behavior I suspect is the intention of the docs saying "Contains only 
explicitly bound arguments." but still seems easily misused when .arguments is 
being used as a frontend for adding additional arguments.

To me just brainstorming again it seems it'd be useful to provide a 
harder-to-misuse frontend, e.g. `BoundArguments.with_arguments(*args, 
**kwargs)` that returns a bound arguments with some additional to-be-bound 
arguments which may end up in `kwargs`.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41745>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to