Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand type alias for completion provider #562

Closed
cdce8p opened this issue Nov 4, 2020 · 6 comments
Closed

Expand type alias for completion provider #562

cdce8p opened this issue Nov 4, 2020 · 6 comments
Labels
enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@cdce8p
Copy link

cdce8p commented Nov 4, 2020

Environment data

  • Language Server version: 2020.10.3
  • OS and version: macOS
  • Python version: 3.9

Actual behaviour

Given the code snippet below, Pylance will only suggest AliasT as type hint for var. dict[int, str] is hidden.

Expected/Suggested behaviour

I often find it useful to directly see the type I'm working with. The type alias is mainly used to keep the code readable and avoid small mistakes when repeatedly writing the type. It might be an idea to display the final type information with the type hit. Some ideas:

var: AliasT -> dict[int, str]

var: AliasT = dict[int, str]

var: AliasT
     dict[int, str]

Code Snippet / Additional information

AliasT = dict[int, str]
var: AliasT

Screen Shot 2020-11-04 at 22 31 56

@github-actions github-actions bot added the triage label Nov 4, 2020
@jakebailey
Copy link
Member

jakebailey commented Nov 4, 2020

We've put a lot of effort into making sure we can preserve the names all the way up to the tooltips, as the names are often more readable than the full expansion (especially for big union types like numpy's ArrayLike, or functions with many many args like in pandas).

I can't really see us wanting to undo this, at least not by default. (Maybe a toggle? Unsure.)

@erictraut
Copy link
Contributor

If you hover over the alias symbol (e.g. AliasT in your example above), you will see the expanded definition. If you hover over some other symbol that refers to the alias (e.g. var in your example above), we display the alias rather than expanding it. This behavior is based on strong feedback we received from many users.

@cdce8p
Copy link
Author

cdce8p commented Nov 4, 2020

Ok. I see it now. I haven't really used hover before.

Just one more observation. Wouldn't it not at least make sense to expand the type alias itself e.g. while writing function arguments? (You can of course hover, but than you would have to move from keyboard to mouse and back)

Screen Shot 2020-11-04 at 23 01 38

@jakebailey
Copy link
Member

That's a good point, I do agree that AliasT: AliasT seems a bit suspect.

@erictraut
Copy link
Contributor

Yes, good point. The completion provider logic should have the same logic as the hover text provider with respect to type aliases.

@jakebailey jakebailey added the enhancement New feature or request label Nov 4, 2020
@github-actions github-actions bot removed the triage label Nov 4, 2020
@erictraut erictraut added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Nov 16, 2020
@cdce8p cdce8p changed the title Expand type hits for type aliases Expand type alias for completion provider Nov 16, 2020
@jakebailey
Copy link
Member

This issue has been fixed in version 2020.11.2, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#2020112-18-november-2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

3 participants