Skip to content

Conversation

@fangyi-zhou
Copy link
Contributor

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

@meta-cla meta-cla bot added the cla signed label Jan 27, 2026
@github-actions

This comment has been minimized.

@fangyi-zhou fangyi-zhou requested a review from kinto0 January 27, 2026 22:37
@migeed-z
Copy link
Contributor

qq: why are mypy results differing? I would have assumed it stays the same if it's just lsp?

@fangyi-zhou
Copy link
Contributor Author

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.

@yangdanny97
Copy link
Contributor

There might be non-determinism in this project's results (perhaps a new regression?), cc @stroxler

@stroxler
Copy link
Contributor

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 <[email protected]>
@github-actions
Copy link

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.

Code completion for overloads are incomplete

4 participants