Skip to content

[ty] Suppress importable completions that are already in scope#25479

Merged
MichaReiser merged 2 commits into
astral-sh:mainfrom
kouhe3:fix/duplicate-auto-import-completions
Jun 3, 2026
Merged

[ty] Suppress importable completions that are already in scope#25479
MichaReiser merged 2 commits into
astral-sh:mainfrom
kouhe3:fix/duplicate-auto-import-completions

Conversation

@kouhe3

@kouhe3 kouhe3 commented May 30, 2026

Copy link
Copy Markdown
Contributor

before
屏幕截图 2026-05-30 181902

after
屏幕截图 2026-05-30 181752

Closes astral-sh/ty#1724

@astral-sh-bot astral-sh-bot Bot added server Related to the LSP server ty Multi-file analysis & type inference labels May 30, 2026
@astral-sh-bot astral-sh-bot Bot changed the title fix duplicate-auto-import-completions [ty] fix duplicate-auto-import-completions May 30, 2026
@astral-sh-bot astral-sh-bot Bot requested a review from lerebear May 30, 2026 10:27
@kouhe3 kouhe3 marked this pull request as draft May 31, 2026 07:22
@kouhe3 kouhe3 force-pushed the fix/duplicate-auto-import-completions branch from 2cce31e to 98b40bf Compare May 31, 2026 08:35
@kouhe3 kouhe3 marked this pull request as ready for review May 31, 2026 08:41
@MichaReiser

Copy link
Copy Markdown
Member

Thank you for looking into this. Can you explain your change and does it correspond to an existing issue?

@AlexWaygood

Copy link
Copy Markdown
Member

I don't know of an open issue about this, but OP reported this on discord before opening the PR: https://discord.com/channels/1039017663004942429/1039017663512449056/1510193925502140468

@MichaReiser

Copy link
Copy Markdown
Member

I think this might be the same as astral-sh/ty#1724

@kouhe3

kouhe3 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

This line is suggested by auto import completions.
But it shouldn't exist because we already import it.
image

So skip it if import().is_none()


These 2 lines is suggested by auto import completions.
(My opinion is that ty.completions.autoImport should not control this suggestion. In terms of naming it doesn't auto import it just reuse imported symbol)

image

So check symbol_text() != name

@MichaReiser MichaReiser assigned MichaReiser and unassigned lerebear Jun 3, 2026
@MichaReiser

Copy link
Copy Markdown
Member

Sorry @lerebear. I didn't realize that this was assigned to you and I already started reviewing (and have a local patch). At this point, I think it makes sense for me to own this review.

@MichaReiser MichaReiser changed the title [ty] fix duplicate-auto-import-completions [ty] Suppress importable completions that are already in scope Jun 3, 2026
@MichaReiser MichaReiser requested a review from ibraheemdev as a code owner June 3, 2026 12:54
@astral-sh-bot

astral-sh-bot Bot commented Jun 3, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 91.94%. The percentage of expected errors that received a diagnostic held steady at 87.09%. The number of fully passing files held steady at 92/134.

@astral-sh-bot

astral-sh-bot Bot commented Jun 3, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot

astral-sh-bot Bot commented Jun 3, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@MichaReiser MichaReiser merged commit 0d4da85 into astral-sh:main Jun 3, 2026
59 checks passed
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.

Duplicate suggestions for already imported "unimported" completions

4 participants