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 <[email protected]>
<http://bugs.python.org/issue19903>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com