[New-bugs-announce] [issue19903] Idle: Use inspect.signature for calltips

Terry J. Reedy report at bugs.python.org
Fri Dec 6 01:21:46 CET 2013


New submission from Terry J. Reedy:

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.

----------
assignee: terry.reedy
components: IDLE
messages: 205339
nosy: terry.reedy
priority: normal
severity: normal
stage: test needed
status: open
title: Idle: Use inspect.signature for calltips
type: behavior
versions: Python 3.3, Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19903>
_______________________________________


More information about the New-bugs-announce mailing list