Skip to content

Conversation

@asukaminato0721
Copy link
Contributor

fix #1090

FindDefinitionItemWithDocstring now tracks an optional docstring_module, attribute fallback searches the executable .py counterpart (loading the module if needed), and records docstrings even when the definition came from a .pyi. The class/assignment context detection was tightened so nested members are resolved reliably.

Hover responses now read docstrings from the recorded module, so the rendered markdown includes the implementation docstring while keeping go‑to-definition on the stub.

@meta-cla meta-cla bot added the cla signed label Nov 7, 2025
@asukaminato0721 asukaminato0721 marked this pull request as ready for review November 7, 2025 12:17
@stroxler stroxler requested a review from kinto0 November 10, 2025 17:11
@kinto0 kinto0 self-assigned this Nov 11, 2025
@meta-codesync
Copy link

meta-codesync bot commented Nov 11, 2025

@kinto0 has imported this pull request. If you are a Meta employee, you can view this in D86780425.

@kinto0
Copy link
Contributor

kinto0 commented Nov 12, 2025

thanks for implementing this! I like the approach a lot. I'll be landing it soon with some modifications, namely moving it up into definition so it works on go-to definition + hover

meta-codesync bot pushed a commit that referenced this pull request Nov 12, 2025
Summary:
D80145015 implemented .py preference on go-to definition, but it did not work for attributes. that's because when we solve a type `a`, `a.attribute` doesn't do another find, it simply goes to the definition of a from solving which is always the .pyi.

asuka implemented a fix for that [here](#1520) for hover docstrings. the intution is to do a second find on attribute definition lookup and look at the AST to find the corresponding definition. this works pretty well, and this diff stack generalizes it to definition.

Reviewed By: connernilsen

Differential Revision: D86814372

fbshipit-source-id: 8b7ed56d74071db55188d448f1eb76f91bcc612d
@kinto0
Copy link
Contributor

kinto0 commented Nov 12, 2025

landed as 4451507

@kinto0 kinto0 closed this Nov 12, 2025
@asukaminato0721 asukaminato0721 deleted the 1090 branch November 12, 2025 20:00
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][Docstring] Docstrings from .py on attributes when base type is from .pyi

3 participants