Show completions from all overloads in LSP#2241
Show completions from all overloads in LSP#2241fangyi-zhou wants to merge 1 commit intofacebook:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
|
qq: why are mypy results differing? I would have assumed it stays the same if it's just lsp? |
I'm not sure, maybe this was introduced by a minor change introduced outside of LSP changes. I'll investigate it later. |
|
There might be non-determinism in this project's results (perhaps a new regression?), cc @stroxler |
|
It's almost certainly nondeterminism (the Unknowns are a hint), I'll disable this project |
Resolves facebook#1122 Previously, the LSP code completion for overload only shows the closest match. This commit shows all possible overloads at the beginning of code completion, and then switches to the closest match afterwards. Ideally we want to only show compatible overloads, but doing so would require re-evaluating overload compatibility with the existing parameters. If we want to do this, we can filter away incompatible overloads when we trace the overload traces (I'm not too sure about this). --- LLM provided summary: When no arguments have been provided yet, show keyword argument completions from all overloads. When arguments have been provided, narrow to the closest matching overload. This is a compromise: ideally we would show params from all overloads that are compatible with the arguments so far, but the infrastructure only tracks a single closest overload, not all compatible ones. Filtering by compatibility would require either extending OverloadedCallee to track all matching overloads or re-checking type compatibility in the completion code. Also changes get_callables_from_call to return Option<usize> for the overload index, distinguishing a matched overload from no match. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
0368fc0 to
dea6b97
Compare
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
kinto0
left a comment
There was a problem hiding this comment.
thanks for the contribution! this doesn't seem to solve the problem exactly:
- it only works for kwarg completions
- it stops working after an argument is provided
I wonder if instead we should change get_callables_from_call to return a list of compatible overloads. then, we can reuse this functionality everywhere and pick the first compatible one if we only support 1 choice.
|
Thanks for the review @kinto0 , could you elaborate on this?
Do we have any other test cases at the moment for other completions? I probably have missed them. |
Summary: Looks like another library where nondeterminism is very rare but does exist, we just saw a PR show a false signal #2241 Reviewed By: ndmitchell Differential Revision: D92006354 fbshipit-source-id: f789cbe7ecab654513a4d9362737043067fae49b
logic was only added in the
right now,
biggest one is signature help (technically not completions), but other ones could be the custom ones like dictionary key completions. |
Summary
Resolves #1122
Previously, the LSP code completion for overload only shows the
closest match. This commit shows all possible overloads at the beginning
of code completion, and then switches to the closest match afterwards.
Ideally we want to only show compatible overloads, but doing so would
require re-evaluating overload compatibility with the existing
parameters. If we want to do this, we can filter away incompatible
overloads when we trace the overload traces (I'm not too sure about this).
LLM provided summary:
When no arguments have been provided yet, show keyword argument
completions from all overloads. When arguments have been provided,
narrow to the closest matching overload. This is a compromise:
ideally we would show params from all overloads that are compatible
with the arguments so far, but the infrastructure only tracks a
single closest overload, not all compatible ones. Filtering by
compatibility would require either extending OverloadedCallee to
track all matching overloads or re-checking type compatibility in
the completion code.
Also changes get_callables_from_call to return Option for the
overload index, distinguishing a matched overload from no match.
Test Plan
python test.py