Fix completion docstrings for stubbed attributes#4101
Conversation
Attribute completions kept the default stub-first definition preference, so they never reached the executable module fallback that hover already uses. Prefer executable definitions for documentation lookup while retaining the stub-derived completion type, and cover the paired .py/.pyi behavior with an LSP regression test.
|
Hi @paranoa233! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@grievejia has imported this pull request. If you are a Meta employee, you can view this in D111468403. |
stroxler
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Summary
.pydefinition when loading documentation for attribute completions.pyistub.pyand.pyimodulesFixes #4057.
Why
Attribute completion documentation used the default stub-first definition preference. When a stub supplied the type but omitted a docstring, completion stopped at the
.pyidefinition instead of using the executable-module fallback that hover already uses.Selecting the executable definition for this documentation-only lookup reuses that existing fallback without changing the stub-derived completion type.
Test plan
cargo +stable-x86_64-pc-windows-gnu test -p pyrefly --test pyrefly_lsp_interaction_tests completion_attribute_prefers_py_docstring_over_pyi --no-fail-fastcargo +stable-x86_64-pc-windows-gnu test -p pyrefly --lib docstring --no-fail-fastcargo +stable-x86_64-pc-windows-gnu test -p pyrefly --test pyrefly_lsp_interaction_tests hover_attribute_prefers_py_docstring_over_pyi --no-fail-fastpy -3.11 test.py --no-test --no-tensor-shapes --no-conformance --no-jsonschemaAI disclosure
This pull request was prepared and submitted by an AI agent. The change was validated with the repository's targeted tests, formatting, and linting workflow.