Terry J. Reedy added the comment:

Let's back up.  The high-level specification for get_argspec is something like 
'Return information that will help programmers write a correct call."  The 
proposed implementation strategy is to combine signature info from signature 
(replacing getfullargspec) and the initial part of the callable docstring.

This goal and strategy mimic help(callable).  So we can use its output as a 
guide, but improve on it when we can and think we should.  This issue could be 
framed as 'catch up with help(callable)' which already switched to signature.

The test examples constitute a low-level specification by example.  As such, 
they should be discussed here before changing the code. Let's consider the ones 
you listed, using 'help(callable)' as a guide.

>>> help(range.__init__)
Help on wrapper_descriptor:
__init__(self, /, *args, **kwargs)
    Initialize self.  See help(type(self)) for accurate signature.

Not very helpful, but if one types 'range.__init__(', one currently sees the 
last line and should see the last two lines in the future.

However, the calltip for 'range(' should not be the above.  When 
type(__init__).__name__ == 'wrapper_descripter, the "fob = ob.__init__" 
replacement should not happen, at least not until we see a case where a 
wrapper_descripter has the real signature.  (Whether is it still needed for 
python-coded classes is a separate issue.)  I don't know if all built-in inits 

>>> help(list.append)
Help on method_descriptor:
append(self, object, /)
    Append object to the end of the list.
>>> help([].append)
Help on built-in function append:
append(object, /) method of builtins.list instance
    Append object to the end of the list.

The signature output is fine with me.  I want future calltips to include it, 
along with the docstring line.

The only issue is the ', /'.  If people can survive it presence in help output, 
ditto for calltips.  But whenever a signature string contains '/', we could 
add, between signature and docstring lines, the following.
"('/' marks preceding arguments as positional-only.)"  If we do this, the 
string should be a global '_positional = ...' so it can be used as-is for 
tests.  I am inclined to try this.

I want to leave the '/' in the signature because there have been multiple 
issues and forum questions about why the equivalent of [].append(object='a') 
does not work.  Now, some built-in parameters are positional-only, some 
keyword-only, and some both.  The hint should make this clear.

----------

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

Reply via email to