wx.py.shell.Shell calltip is not correct for decorated functions and methods.
Operating system: Windows 10 wxPython version & source: 4.1.1 (pypi) --> 4.2.0a1.dev5449+3ac1e526 msw (phoenix) wxWidgets 3.2.0 RC1 Python version & source: 3.10.4,
Description of the problem:
-
The calltip doesn't display the correct signature of the decorated functions (see fig. 1).
-
DeprecationWarning is displayed when a calltip is shown (Launch with option
-Wdsuch as$ python -Wd <script.py>to show the warning messages)...\Phoenix\wx\py\introspect.py:179: DeprecationWarning:
formatargspecis deprecated since Python 3.5. Usesignaturedirectly.### For example, when you typed as below, >>> frm.shell.about( ^ then, a calltip is displayed and the warning messages will appear in the command prompt. -
For more convenience, type-hints and return-value annotation should be eliminated.
Code Example (click to expand)
import wx
import inspect
from py.shell import Shell
from functools import wraps
def deco(f):
@wraps(f)
def _f(*args, **kwargs):
return f(*args, **kwargs)
return _f
def func(x, /, y, z=3, *args, value:int=0, **kwargs) -> int:
"""function doc:str"""
return x * y + z
func2 = deco(func)
if __name__ == "__main__":
import __main__ as this
app = wx.App()
frm = wx.Frame(None)
frm.shell = Shell(frm, locals=this.__dict__)
frm.Show()
app.MainLoop()
Fig. 1: In this snippet of code, func is a normal function and func2 is the decorated function. The signature of func is correct but func2 is not.