microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.67k stars 770 forks source link

Clearer tooltips for nested classes #6049

Closed lanzz closed 3 days ago

lanzz commented 1 week ago

Not sure if this is a Pylance or a Pyright issue, or even a VS Code issue.

In VS Code, the tooltip for nested classes shows only the base name of the class, which can be unclear:

class Foo:
    class Inner: ...

class Bar:
    class Inner: ...

a = Foo.Inner()
b = Bar.Inner()

Hovering over either a and b shows (variable) a: Inner and (variable) b: Inner, which obscures the fact that they're actually instances of different classes. It will be helpful if the qualified class name is displayed instead ((variable) a: Foo.Inner / (variable) b: Bar.Inner).

heejaechang commented 4 days ago

it is a spec question. we do disambiguate type name within same type such as A[Foo.Inner, Bar.Inner] but we won't do it for ones like in this issue.

should we always put full type name somewhere? or full type name everywhere? I think all has its con and pros.

lanzz commented 4 days ago

User setting then perhaps? I can see how even the same user might want it different ways in different workspaces. Or could it be sensitive to a wider context, i.e. show full names only if there is actual ambiguity between classes defined in the codebase? It might be enough if that's done even in a single-file context.

rchiodo commented 3 days ago

Transferring to a discussion for upvotes/discussion.