Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Feature Request: View docstrings inside of import paths. #2551

Closed
hacker-DOM opened this issue Apr 8, 2022 · 4 comments
Closed

Feature Request: View docstrings inside of import paths. #2551

hacker-DOM opened this issue Apr 8, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@hacker-DOM
Copy link

hacker-DOM commented Apr 8, 2022

Hi there!

When I have a module (file) f.py with

__doc__ = "xyz"

And in a different file

import my_package.f

i would expect that triggering editor.action.showDefinitionPreviewHover on f would show a hover with contents "xyz".

However, it only shows (module) f.

Thank you for considering my issue!

@github-actions github-actions bot added the triage label Apr 8, 2022
@erictraut
Copy link
Contributor

Module-level docstrings are supported if you have a docstring at the top of the module. They are not supported if you dynamically assign a value to the __doc__ variable. Keep in mind that a static type analyzer doesn't actually run the code.

@hacker-DOM
Copy link
Author

hacker-DOM commented Apr 8, 2022

Thank you for your answer, however, I am still getting unexpected behavior. I have tried to document this.

tldr: it only works for relative imports, not for absolute imports

Thanks 🙏

@erictraut
Copy link
Contributor

Docstrings are displayed for symbols, not for import paths. In the expression from a.b.c import d, a.b.c is an import path (as is a and a.b); d is the imported symbol. That explains the difference you're seeing.

It sounds like you are interested in seeing module docstrings for module paths when they refer to a module. That's a reasonable enhancement request.

@hacker-DOM hacker-DOM changed the title Question: Are module-level docstrings supported? Feature Request: View docstrings inside of import paths. Apr 9, 2022
@judej judej added the enhancement New feature or request label Apr 11, 2022
@github-actions github-actions bot removed the triage label Apr 11, 2022
@judej
Copy link
Contributor

judej commented Apr 18, 2022

Moving this issue to discussion as an enhancement request for comments and upvotes.

@microsoft microsoft locked and limited conversation to collaborators Apr 18, 2022
@judej judej converted this issue into discussion #2580 Apr 18, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants