[issue21117] inspect: PartialSignature and PartialParameter classes

2014-03-31 Thread Yury Selivanov
New submission from Yury Selivanov: There is a small detail in the current Signature class implementation, in regards to how partial signatures are treated. Consider the following example: def foo(a, b): pass foo_partial = functools.partial(foo, 'spam') Now, the signature of

[issue21117] inspect: PartialSignature and PartialParameter classes

2014-03-31 Thread R. David Murray
R. David Murray added the comment: I believe it is a python invariant that a == b implies hash(a) == hash(b). I don't see why the two signatures should be equal. I'm not even sure why the bound argument shows up in the signature of the partial. That surprises me. -- nosy:

[issue21117] inspect: PartialSignature and PartialParameter classes

2014-03-31 Thread Nick Coghlan
Nick Coghlan added the comment: On 1 Apr 2014 07:36, Nick Coghlan rep...@bugs.python.org wrote: Nick Coghlan added the comment: The already bound arguments should be treated as additional keyword-only arguments, and already bound positional arguments hidden completely. Oops: already bound

[issue21117] inspect: PartialSignature and PartialParameter classes

2014-03-31 Thread Yury Selivanov
Yury Selivanov added the comment: @Nick: Oops: already bound positional-*only* arguments should be hidden. Hm, good catch. I'm not sure we currently do this. I'll check if this needs to be fixed (in 3.4.1 too). I'm +0 on new types to clean that up if necessary, but would prefer it if we

[issue21117] inspect: PartialSignature and PartialParameter classes

2014-03-31 Thread Nick Coghlan
Nick Coghlan added the comment: On 1 Apr 2014 08:17, Yury Selivanov rep...@bugs.python.org wrote: I'm +0 on new types to clean that up if necessary, but would prefer it if we could just improve the translation to ordinary signature objects instead. I'm not sure I understand what you mean

[issue21117] inspect: PartialSignature and PartialParameter classes

2014-03-31 Thread Yury Selivanov
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

[issue21117] inspect: PartialSignature and PartialParameter classes

2014-03-31 Thread Yury Selivanov
Yury Selivanov added the comment: @Nick: oh, it took me some time to realize that your suggestion to transform positional-or-keyword to keyword-only parameters is correct. If we do this, we no longer need '_partial_kwarg' hack. I'll work on the patch. Thank you. --