[issue21117] inspect: PartialSignature and PartialParameter classes
Yury Selivanov
report at bugs.python.org
Tue Apr 1 02:01:43 CEST 2014
Yury Selivanov added the comment:
@Nick:
Agreed on positional-only stuff.
> If arguments bound by position disappear from the signature, and those
> bound by keyword are mapped to keyword-only parameters with a default, we
> should get a valid and accurate signature.
But what about my example from the first message:
def foo(a, b): pass
foo_partial = functools.partial(foo, 'spam')
'foo_partial' now has the following signature: (a='spam', b); where 'a' is a positional_or_keyword parameter, i.e. you can still do 'foo_partial(10, 20)', or 'foo_partial(b=20, a=10)'.
(a='spam', b) is not a valid python pure function signature, but is a perfectly valid signature of partial function. And since its arguments aren't positional-only, we shouldn't hide anything.
That's why I have this private '_partial_kwarg' attribute, which I don't like and want to remove by adding a PartialParameter subclass. Otherwise, we have something that is hidden and non-documented, but affects Parameter.__hash__ and some other logic.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21117>
_______________________________________
More information about the Python-bugs-list
mailing list