Phoenix icon indicating copy to clipboard operation
Phoenix copied to clipboard

wx.py.shell.Shell calltip is not correct for decorated functions and methods.

Open komoto48g opened this issue 3 years ago • 0 comments

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:

  1. The calltip doesn't display the correct signature of the decorated functions (see fig. 1).

  2. DeprecationWarning is displayed when a calltip is shown (Launch with option -Wd such as $ python -Wd <script.py> to show the warning messages)

    ...\Phoenix\wx\py\introspect.py:179: DeprecationWarning: formatargspec is deprecated since Python 3.5. Use signature directly.

     ### 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.
    
  3. 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()

introspect-1 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.

komoto48g avatar Jul 20 '22 17:07 komoto48g