Visitar URL original
[ty] Avoid stale I/O diagnostics when closing deleted files by MichaReiser · Pull Request #28988 · astral-sh/ruff · GitHub
Skip to content

[ty] Avoid stale I/O diagnostics when closing deleted files - #28988

Merged
MichaReiser merged 4 commits into
mainfrom
micha/ty-close-deleted-file
Oct 1, 2026
Merged

MichaReiser merged 4 commits into
mainfrom
micha/ty-close-deleted-file

Conversation

@MichaReiser

@MichaReiser MichaReiser commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Remove files that no longer exist from the project when handling didClose, preventing workspace diagnostics from reporting a spurious I/O error before the file watcher catches up.

Closes astral-sh/ty-vscode#547.

@MichaReiser MichaReiser added the ty The ty type checker label Sep 29, 2026
@astral-sh-bot astral-sh-bot Bot added the server Related to the Ruff or ty LSP server label Sep 29, 2026
@MichaReiser
MichaReiser marked this pull request as ready for review September 29, 2026 09:02
@MichaReiser
MichaReiser requested a review from a team as a code owner September 29, 2026 09:02
@astral-sh-bot
astral-sh-bot Bot requested a review from lerebear September 29, 2026 09:02
@MichaReiser MichaReiser changed the title [ty] Avoid I/O diagnostics when closing deleted files [ty] Avoid stale I/O diagnostics when closing deleted files Sep 29, 2026

@lerebear lerebear left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨

Comment on lines +1467 to +1473
server.write_file(path, source)?;
server.did_change_watched_file(path, FileChangeType::Created);
let recreated = server.workspace_diagnostic_request(None, None);
insta::assert_snapshot!(condensed_workspace_diagnostic_snapshot(recreated), @r#"
file://<temp_dir>/src/deleted.py
0:13..0:20[ERROR]: Object of type `Literal["wrong"]` is not assignable to `int`
"#);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might consider removing this last block: it isn't really related to the code that changed, and I expect this state progression is already tested elsewhere.

Comment thread crates/ty_server/src/session.rs
@MichaReiser
MichaReiser merged commit aa9a1ff into main Oct 1, 2026
107 of 109 checks passed
@MichaReiser
MichaReiser deleted the micha/ty-close-deleted-file branch October 1, 2026 13:19
@codspeed

codspeed Bot commented Oct 1, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 4.26%

⚡ 1 improved benchmark
✅ 161 untouched benchmarks
⏩ 60 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ WallTime auto_imports[regular-package/after-module-create] 25.9 ms 24.9 ms +4.26%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing micha/ty-close-deleted-file (ac79bec) with main (2d25346)

Open in CodSpeed

Footnotes

  1. 60 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

server Related to the Ruff or ty LSP server ty The ty type checker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Failed to read file" error when deleting a file with "ty.diagnosticMode": "workspace"

2 participants