Skip to content

Show annotated-doc parameter docs in completion items - #5867

Closed
kinto0 wants to merge 2 commits into
pyrefly-org:mainfrom
kinto0:export-D135986769
Closed

kinto0 wants to merge 2 commits into
pyrefly-org:mainfrom
kinto0:export-D135986769

Conversation

@kinto0

@kinto0 kinto0 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary:
Stack context: show Doc(...) parameter docs (annotated-doc, as FastAPI uses) in completion items, as hover already does.
Plan step: the fix.

  • What: completion item documentation now shows the docstring followed by the Doc(...) documentation of each parameter, in the same format as hover. This applies to name completions (such as app = FastAPI<ctrl+space>) and attribute completions.
  • Why: a FastAPI user asked for it. Hover already shows these docs, but completion showed only the docstring, though the export already holds the parameter Doc ranges.
  • Hover and completion now share format_parameter_docs, so the two stay the same.

VS Code with FastAPI 0.165.0, ctrl+space after app = FastAPI:

Before After

After, api.get method completion (details pane scrolled to the parameter docs):

Plain function Depends, ctrl+space after dep = Depends (details pane scrolled to the end):

Before After

landed-with-radar-review

Differential Revision: D135986769

Summary:
Stack context: show `Doc(...)` parameter docs (annotated-doc, as FastAPI uses) in completion items, as hover already does.
Plan step: test of current behavior.

- What: add a completion test for a class and a method whose parameters use `Annotated[..., Doc(...)]`.
- Why: completion shows only the docstring today. Hover shows the parameter docs too. The next diff fixes completion, and this test shows the change.

___

landed-with-radar-review

Differential Revision: D135986768
Summary:
Stack context: show `Doc(...)` parameter docs (annotated-doc, as FastAPI uses) in completion items, as hover already does.
Plan step: the fix.

- What: completion item documentation now shows the docstring followed by the `Doc(...)` documentation of each parameter, in the same format as hover. This applies to name completions (such as `app = FastAPI<ctrl+space>`) and attribute completions.
- Why: a FastAPI user asked for it. Hover already shows these docs, but completion showed only the docstring, though the export already holds the parameter `Doc` ranges.
- Hover and completion now share `format_parameter_docs`, so the two stay the same.

___

landed-with-radar-review

Differential Revision: D135986769
@meta-cla meta-cla Bot added the cla signed label Dec 3, 2026
@meta-codesync

meta-codesync Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

@kinto0 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D135986769.

kinto0 added a commit to kinto0/pyrefly that referenced this pull request Dec 3, 2026
kinto0 added a commit to kinto0/pyrefly that referenced this pull request Dec 3, 2026
kinto0 added a commit to kinto0/pyrefly that referenced this pull request Dec 3, 2026
kinto0 added a commit to kinto0/pyrefly that referenced this pull request Dec 3, 2026
kinto0 added a commit to kinto0/pyrefly that referenced this pull request Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@meta-codesync meta-codesync Bot closed this in 06348a1 Dec 3, 2026
@meta-codesync meta-codesync Bot added the Merged label Dec 3, 2026
@meta-codesync

meta-codesync Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

This pull request has been merged in 06348a1.

@kinto0
kinto0 deleted the export-D135986769 branch December 3, 2026 18:22
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.

1 participant