Skip to content

[ty] Preserve typing-only completion ranking in TYPE_CHECKING blocks - #27549

Open
AlexWaygood wants to merge 2 commits into
mainfrom
alex/type-checking-completion-ranking
Open

[ty] Preserve typing-only completion ranking in TYPE_CHECKING blocks#27549
AlexWaygood wants to merge 2 commits into
mainfrom
alex/type-checking-completion-ranking

Conversation

@AlexWaygood

@AlexWaygood AlexWaygood commented Aug 6, 2026

Copy link
Copy Markdown
Member

Summary

Certain symbols are known not to exist at runtime (only at type-checking time), and we downrank these symbols in autocomplete suggestions in .py files. We don't need to do any such downranking when the user's cursor is inside an if TYPE_CHECKING block, however, information which is now easily retrievable from the semantic index. This PR updates our ranking logic to check for this before downranking type-check-only symbols.

Test plan

Various scenarios in ty_completion_eval were updated.

@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Aug 6, 2026 — with ChatGPT Codex Connector
@AlexWaygood AlexWaygood added the server Related to the LSP server label Aug 6, 2026
@AlexWaygood
AlexWaygood marked this pull request as ready for review August 6, 2026 14:14
@AlexWaygood
AlexWaygood requested review from a team as code owners August 6, 2026 14:14
@astral-sh-bot
astral-sh-bot Bot requested a review from MichaReiser August 6, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

server Related to the LSP server ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant