Author terry.reedy
Recipients terry.reedy
Date 2013-12-06.00:21:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1386289306.22.0.0855188637089.issue19903@psf.upfronthosting.co.za>
In-reply-to
Content
Change idlelib.CallTips.get_argspec to use inspect.signature, new in 3.3, instead of inspect.getfullargspec and inspect.formatargspec. One thing it handles better is a namedtuple class, which has a C-coded __init__ inherited from object a Python-coded __new__ written by namedtuple. Signature() will also handle C-coded functions if and when Argument Clinic (new in 3.4) adds signature information.

from collections import namedtuple
from inspect import signature

Point = namedtuple('Point', 'x y')
print(signature(Point.__new__))
# '(_cls, x, y)'
print(signature(Point))
# '(x, y)'

Note that str (called by print) is needed to get the desired string form.

There are tests in CallTips.py, but they should be converted to unittest, moved to idle_test/test_calltips.py, changed to match new output detail, and expanded to include new examples.
History
Date User Action Args
2013-12-06 00:21:46terry.reedysetrecipients: + terry.reedy
2013-12-06 00:21:46terry.reedysetmessageid: <1386289306.22.0.0855188637089.issue19903@psf.upfronthosting.co.za>
2013-12-06 00:21:46terry.reedylinkissue19903 messages
2013-12-06 00:21:45terry.reedycreate