[ty] Add 'remove unused ignore comment' code action#21582
Conversation
a40403a to
820ff0c
Compare
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
820ff0c to
8850253
Compare
|
ccfb4ef to
58b48c7
Compare
| [dependencies] | ||
| ruff_db = { workspace = true } | ||
| ruff_annotate_snippets = { workspace = true } | ||
| ruff_diagnostics = { workspace = true } |
There was a problem hiding this comment.
We should probably fold ruff_diagnostics into ruff_db. There's really not much in there but this seemed unrelated to this PR
There was a problem hiding this comment.
I tried this and it ran into circular reference nastiness (stuff depends on ruff_diagnostics that ruff_db in turn depends on, I guess?). I opted to just pub use the relevant items in ruff_db.
| let code = &self.source[*code_range]; | ||
| let range = if codes.len() == 1 { | ||
| comment.range | ||
| } else { | ||
| *code_range | ||
| }; |
There was a problem hiding this comment.
This is now handled by the unused suppression lint itself
58b48c7 to
8c5b83e
Compare
8c5b83e to
88902c8
Compare
crates/ty_python_semantic/resources/mdtest/suppressions/ty_ignore.md
Outdated
Show resolved
Hide resolved
AlexWaygood
left a comment
There was a problem hiding this comment.
Very excited to see this happen! A few nits from skimming
b97e848 to
a67e6f2
Compare
88902c8 to
5d5803c
Compare
b2cc26b to
7efe928
Compare
AlexWaygood
left a comment
There was a problem hiding this comment.
🚀
(Didn't review the ty_server code in depth)
Gankra
left a comment
There was a problem hiding this comment.
Rad, yeah this is exactly the minimal version that makes sense.
| [dependencies] | ||
| ruff_db = { workspace = true } | ||
| ruff_annotate_snippets = { workspace = true } | ||
| ruff_diagnostics = { workspace = true } |
There was a problem hiding this comment.
I tried this and it ran into circular reference nastiness (stuff depends on ruff_diagnostics that ruff_db in turn depends on, I guess?). I opted to just pub use the relevant items in ruff_db.
* main: [ty] Implement `typing.override` (astral-sh#21627) [ty] Avoid expression reinference for diagnostics (astral-sh#21267) [ty] Improve autocomplete suppressions of keywords in variable bindings [ty] Only suggest completions based on text before the cursor Implement goto-definition and find-references for global/nonlocal statements (astral-sh#21616) [ty] Inlay Hint edit follow up (astral-sh#21621) [ty] Implement lsp support for string annotations (astral-sh#21577) [ty] Add 'remove unused ignore comment' code action (astral-sh#21582) [ty] Refactor `CheckSuppressionContext` to use `DiagnosticGuard` (astral-sh#21587) [ty] Improve several "Did you mean?" suggestions (astral-sh#21597) [ty] Add more and update existing projects in `ty_benchmark` (astral-sh#21536) [ty] fix ty playground initialization and vite optimization issues (astral-sh#21471)
Summary
This PR adds a code action to remove unused ignore comments.
This PR also includes some infrastructure boilerplate to set up code actions in the editor:
snapshot-diagnosticsto render fixes--output-format=fullUnnecessarytag tounused-ignore-commentdiagnosticsThe same fix can be used on the CLI once we add
ty fixNote:
unused-ignore-commentis currently disabled by default.Screen.Recording.2025-11-22.at.22.36.26.mov