Bug 289253 - Variable aliasing a function gets confusing tooltips
Summary: Variable aliasing a function gets confusing tooltips
Status: CONFIRMED
Alias: None
Product: kdev-python
Classification: Developer tools
Component: User interface (show other bugs)
Version: git master
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: 1.2.3
Assignee: Sven Brauch
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-18 04:55 UTC by Nicolás Alvarez
Modified: 2016-12-30 15:35 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Screenshot showing the tooltip (6.46 KB, image/png)
2011-12-18 04:55 UTC, Nicolás Alvarez
Details

Note You need to log in before you can comment on or make changes to this bug.
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...