[ty] report only dead annotation-only locals as unused#24811
[ty] report only dead annotation-only locals as unused#24811MichaReiser merged 2 commits intoastral-sh:mainfrom
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 87.94%. The percentage of expected errors that received a diagnostic held steady at 83.36%. The number of fully passing files held steady at 79/133. |
Memory usage reportMemory usage unchanged ✅ |
| /// without broader reference analysis. Bare local annotations (`x: int`) are also | ||
| /// reported, but only if the symbol is neither bound nor used elsewhere in the scope. | ||
| #[salsa::tracked(returns(ref))] | ||
| pub fn unused_bindings(db: &dyn Db, file: ruff_db::files::File) -> Vec<UnusedBinding> { |
There was a problem hiding this comment.
The function name is a bit misleading now because it also reports declaration only locals, not just bindings. unused_locals would better for the current shape, but I’m leaving the rename for now to keep churn down and until we have defined the scope of any future non-local reporting.
There was a problem hiding this comment.
Alternatively, we could skip declaration only locals from reporting entirely, but for comparison, pyright also reports them.
There was a problem hiding this comment.
I think we should keep reporting unused locals. Renaming it to unused_locals sounds reasonable.
|
| /// without broader reference analysis. Bare local annotations (`x: int`) are also | ||
| /// reported, but only if the symbol is neither bound nor used elsewhere in the scope. | ||
| #[salsa::tracked(returns(ref))] | ||
| pub fn unused_bindings(db: &dyn Db, file: ruff_db::files::File) -> Vec<UnusedBinding> { |
There was a problem hiding this comment.
I think we should keep reporting unused locals. Renaming it to unused_locals sounds reasonable.
Closes astral-sh/ty#3322
Summary
Fixes unused-local handling for annotation-only declarations like
a: int.Test Plan
Added tests associated with the fix.