[ty] Prefer standard library over third party libraries for import completions.#25108
Draft
lerebear wants to merge 2 commits into
Draft
[ty] Prefer standard library over third party libraries for import completions.#25108lerebear wants to merge 2 commits into
lerebear wants to merge 2 commits into
Conversation
909af18 to
cf36bf8
Compare
e2eaa27 to
fb244ca
Compare
fb244ca to
6c9de06
Compare
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
This changes ty’s completion ranking so identical-label auto-import candidates prefer standard-library symbols over third-party re-exports. For example, Path now ranks pathlib.Path ahead of a third-party Path re-export, and the completion-eval task now ranks re.fullmatch ahead of regex.fullmatch. Unrelated labels keep the prior fallback behavior, so a different third-party name can still rank above a stdlib candidate.
Closes astral-sh/ty#3325.
Test Plan
Please see included test.