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

Pylance should be able to recognize docstrings for type aliases #1815

Closed
macintacos opened this issue Sep 13, 2021 · 7 comments
Closed

Pylance should be able to recognize docstrings for type aliases #1815

macintacos opened this issue Sep 13, 2021 · 7 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

@macintacos
Copy link

I can't seem to get VSCode to recognize docstrings for type aliases that I define. Say I have the following type alias and docstring:

SomeType = List[Union[dict, str]]
"""Here's some documentation about SomeType"""

For an example of how I'd like it to work, Pycharm shows the following when I hover over SomeType:

CleanShot PyCharm 2021-09-13 at 17 44 33

In VSCode I only seem to see documentation related to the underlying types instead of the documentation I provided for the alias:

CleanShot Code 2021-09-13 at 17 46 57

In an ideal world, I'd be able to see both the underlying type documentation and the documentation that I added for the alias myself, but honestly I'd settle for at least always showing the documentation that I specified in the project itself.

Can this be added? This felt like something that should be implemented in Pylance, but I wasn't 100% sure - please feel free to move it to whatever project makes the most sense!

@jakebailey
Copy link
Member

Interesting; this should have worked as we explicitly intend to support these types of docstrings (see #1576).

image

This may be something specific to aliases.

@erictraut
Copy link
Contributor

We do support variable doc strings, but type aliases are distinct from other types of variables. It should be feasible to extend the support for type aliases.

@jakebailey
Copy link
Member

Yep, it's a small change (I'm making it now).

@jakebailey
Copy link
Member

In this case, it's hitting the fact that it's an instantiable type before it hits the code that checks if it's a variable.

@jakebailey jakebailey added the enhancement New feature or request label Sep 13, 2021
@github-actions github-actions bot removed the triage label Sep 13, 2021
@jakebailey jakebailey added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Sep 13, 2021
@jakebailey
Copy link
Member

This will be fixed in the next release.

@macintacos
Copy link
Author

That's great, thanks!

@macintacos macintacos changed the title Pylance should be able to recordnize docstrings for type aliases Pylance should be able to recognize docstrings for type aliases Sep 14, 2021
@jakebailey
Copy link
Member

This issue has been fixed in version 2021.9.2, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202192-16-september-2021

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