Skip to content

fix Render callable protocols in hover as the signature of __call__ rather than by name #2832#2940

Open
asukaminato0721 wants to merge 1 commit intofacebook:mainfrom
asukaminato0721:2832
Open

fix Render callable protocols in hover as the signature of __call__ rather than by name #2832#2940
asukaminato0721 wants to merge 1 commit intofacebook:mainfrom
asukaminato0721:2832

Conversation

@asukaminato0721
Copy link
Copy Markdown
Contributor

Summary

Fixes #2832

coercing the hovered type to its callable form only when the cursor is actually on the callee.

preserves the existing constructor special case and avoids changing plain attribute hovers.

Test Plan

add test

@meta-cla meta-cla bot added the cla signed label Mar 26, 2026
@asukaminato0721 asukaminato0721 marked this pull request as ready for review March 26, 2026 22:02
Copilot AI review requested due to automatic review settings March 26, 2026 22:02
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes hover rendering for callable protocol attributes so that, when hovering the callee in a call expression, the hover displays the __call__ signature (instead of showing an attribute named __call__). This aligns hover behavior with how callable instances are already rendered and avoids affecting non-call-site (plain attribute) hovers.

Changes:

  • Only coerce the hovered type to a callable when the hover position is actually within the callee range of a call expression.
  • Preserve the existing “constructor call” special-case behavior for hover display.
  • Add a regression test covering callable protocol attributes used as callees.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pyrefly/lib/lsp/wasm/hover.rs Gates callable coercion behind “hover is on callee” so call-site hovers show __call__ signatures without impacting other hovers.
pyrefly/lib/test/lsp/hover.rs Adds a regression test ensuring callable protocol attributes render the __call__ signature on hover at the call site.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown

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

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.

Render callable protocols in hover as the signature of __call__ rather than by name

2 participants