Skip to content

feat: added a fallback to class docstring - #5285

Open
jny0444 wants to merge 1 commit into
facebook:mainfrom
jny0444:feat/hover-class-docstring-lsp
Open

jny0444 wants to merge 1 commit into
facebook:mainfrom
jny0444:feat/hover-class-docstring-lsp

Conversation

@jny0444

@jny0444 jny0444 commented Oct 19, 2026

Copy link
Copy Markdown

Hovering a constructor call now shows the class docstring when __init__ or __new__ has none.

Fixes #5254

Calling a class, as in foo = MyClass(bar), resolves hover to __init__ or __new__. Those methods often have no docstring, so the tooltip was empty even when the class documented itself. Hover still prefers a nonempty method docstring. When that docstring is missing or blank, it uses the class docstring instead, preferring a stub over the implementation. Go-to-definition still lands on the method.

Test plan

  • cargo test -p pyrefly --lib test::lsp::hover::
  • Covered __init__ with no docstring, __new__ with no docstring, and the case where neither the method nor the class has a docstring.

@meta-codesync

meta-codesync Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D126052137. (Because this pull request was imported automatically, there will not be any future comments.)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hover message should show doc string for class when __init__ has none

1 participant