Skip to content

[ty] Prefer standard library over third party libraries for import completions.#25108

Draft
lerebear wants to merge 2 commits into
mainfrom
lerebear/push-kzzlywlnxkmk
Draft

[ty] Prefer standard library over third party libraries for import completions.#25108
lerebear wants to merge 2 commits into
mainfrom
lerebear/push-kzzlywlnxkmk

Conversation

@lerebear
Copy link
Copy Markdown
Contributor

@lerebear lerebear commented May 11, 2026

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.

@astral-sh-bot astral-sh-bot Bot added server Related to the LSP server ty Multi-file analysis & type inference labels May 11, 2026
@lerebear lerebear force-pushed the lerebear/push-kzzlywlnxkmk branch 3 times, most recently from 909af18 to cf36bf8 Compare May 12, 2026 16:46
@lerebear lerebear changed the title Prefer standard library over third party libraries for import completions. [ty] Prefer standard library over third party libraries for import completions. May 13, 2026
@lerebear lerebear force-pushed the lerebear/push-kzzlywlnxkmk branch 14 times, most recently from e2eaa27 to fb244ca Compare May 16, 2026 05:26
@lerebear lerebear force-pushed the lerebear/push-kzzlywlnxkmk branch from fb244ca to 6c9de06 Compare May 16, 2026 06: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.

Import suggestions from standard library are ranked lower than from third-party packages

1 participant