Bug 289253

Summary: Variable aliasing a function gets confusing tooltips
Product: [Developer tools] kdev-python Reporter: Nicolás Alvarez <nalvarez>
Component: User interfaceAssignee: Sven Brauch <mail>
Status: CONFIRMED ---    
Severity: wishlist CC: mail, mail
Priority: NOR    
Version: git master   
Target Milestone: 1.2.3   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Screenshot showing the tooltip

Description Nicolás Alvarez 2011-12-18 04:55:22 UTC
Created attachment 66849 [details]
Screenshot showing the tooltip

If I declare a function 'foo', and then create a variable 'bar' aliasing it, the tooltip of 'bar' everywhere (both on the variable declaration and on its uses) is identical to the tooltip of 'foo', which is confusing.

def foo(n): return 4
bar = foo
x = bar()

The tooltip of 'bar' in both places (decl and use) says "int foo( mixed n )". The name 'bar' doesn't appear anywhere in the tooltip. It even says the declaration is in the first line of the file rather than the second.


Eike Hein on #kdevelop suggested showing "int bar(mixed n), defined as foo in test.py:2" or "alias bar for int foo(mixed n)". He also mentioned that the Wing IDE shows it like this:

Symbol: bar
  Likely type: callable function foo
    def foo()

However, that may be too much trouble. I'd be happy for now if at least you could make it show "function int (mixed) bar" or something like that, like it  currently happens for function arguments that were deduced to be of function type themselves:

def x(f): pass
x(foo)

The tooltip of 'f' says "function int (mixed) f, Scope: x, Kind: Variable".


I don't know about kdev-python's code, but I guess it might be tricky to fix this while not breaking features that currently work correctly, such as having bar('aaa') help to deduce that foo's argument is a string...
Comment 1 Francis Herne 2016-12-30 15:35:49 UTC
Should point out that the current behaviour matches the reference interpreter:

>>> def foo(n): return 4
>>> bar = foo
>>> bar
<function foo at 0x7f1ab94389d8>

It's not really hiding the current name; you have to mouse-over that to see this tooltip in the first place...