Skip to content

[B007] Add Unnecessary tag for certain unused loop control variables (editor dimming) #23452

@denyszhak

Description

@denyszhak

Summary

B007 reports unused loop control variables, but the emitted diagnostic doesn’t include DiagnosticTag::Unnecessary, so editors don’t dim these names.

I’m not sure whether omission of the tag is intentional, but I don’t see a downside for the Certain path.
For Uncertain cases (may not be used), we can keep behaviour unchanged to avoid possible false-positives.

(Noticed while working on astral-sh/ty#2607)

Version

ruff 0.14.8 (9d4f1c6 2025-12-04)

Metadata

Metadata

Assignees

No one assigned

    Labels

    diagnosticsRelated to reporting of diagnostics.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions