Skip to content

Fix completion docstrings for stubbed attributes#4101

Open
paranoa233 wants to merge 1 commit into
facebook:mainfrom
paranoa233:agent/fix-completion-docstrings
Open

Fix completion docstrings for stubbed attributes#4101
paranoa233 wants to merge 1 commit into
facebook:mainfrom
paranoa233:agent/fix-completion-docstrings

Conversation

@paranoa233

Copy link
Copy Markdown

Summary

  • use the executable .py definition when loading documentation for attribute completions
  • keep completion types and signatures sourced from the .pyi stub
  • add an LSP regression test covering paired .py and .pyi modules

Fixes #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 .pyi definition 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-fast
  • cargo +stable-x86_64-pc-windows-gnu test -p pyrefly --lib docstring --no-fail-fast
  • cargo +stable-x86_64-pc-windows-gnu test -p pyrefly --test pyrefly_lsp_interaction_tests hover_attribute_prefers_py_docstring_over_pyi --no-fail-fast
  • py -3.11 test.py --no-test --no-tensor-shapes --no-conformance --no-jsonschema

AI 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.

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.
@meta-cla

meta-cla Bot commented Jul 10, 2026

Copy link
Copy Markdown

Hi @paranoa233!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@paranoa233 paranoa233 marked this pull request as ready for review July 10, 2026 07:58
@meta-cla meta-cla Bot added the cla signed label Jul 10, 2026
@meta-cla

meta-cla Bot commented Jul 10, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-codesync

meta-codesync Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

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

@stroxler stroxler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@kinto0 kinto0 assigned kinto0 and grievejia and unassigned kinto0 Jul 10, 2026
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.

"Docstrings from .py when type is from .pyi" is not working

4 participants