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
Open
fix Render callable protocols in hover as the signature of __call__ rather than by name #2832#2940asukaminato0721 wants to merge 1 commit intofacebook:mainfrom
asukaminato0721 wants to merge 1 commit intofacebook:mainfrom
Conversation
There was a problem hiding this comment.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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