[ty] Don't create a related diagnostic for the primary annotation of sub-diagnostics by MichaReiser · Pull Request #21845 · astral-sh/ruff (original) (raw)

Summary

Addresses the 'too many "Python 3.7 was assumed" diagnostics issue raised in this comment

We already skip the primary annotation when creating related diagnostics for the main diagnostic, but we failed to do so for sub-diagnostics, which results in duplicated related information diagnostics.

We need to skip the primary annotation because we already use that range when generating related information for the subdiagnostic.

Test Plan

Screenshot 2025-12-08 at 14 48 57