pyright-lsp plugin promotes hint-level DiagnosticTag.Unnecessary into conversation context

Resolved 💬 4 comments Opened Feb 18, 2026 by othercriteria Closed Apr 13, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The pyright-lsp@claude-plugins-official plugin injects <new-diagnostics> for LSP hint-level diagnostics tagged with DiagnosticTag.Unnecessary. These are false positives that disagree with the pyright CLI — they consume context tokens and cause the model to attempt unnecessary "fixes."

This is not a staleness issue (cf. #17979). The diagnostics are consistently reported by the LSP server but correctly suppressed by the pyright CLI. The problem is that Claude Code doesn't filter by diagnostic severity before injecting into conversation context.

Reproduction

  1. Enable pyright-lsp@claude-plugins-official
  2. Project uses typeCheckingMode = "strict" in pyproject.toml
  3. Write standard Python with _-prefixed unused variables:
# Tuple unpacking — _accrued_cash intentionally unused
(account_id, cash, nav, gmv, _accrued_cash, available_funds) = summary

# Tool handler — _args intentionally unused
async def get_vix_tool(_args: dict[str, Any]) -> dict[str, Any]:
    return fetch_vix()
  1. Edit or read the file

Expected: No diagnostics. Pyright CLI correctly exempts _-prefixed variables (pyright --outputjson → 0 errors, 0 warnings, 0 informations).

Actual: Claude Code injects:

<new-diagnostics>The following new diagnostic issues were detected:

calc_account.py:
  ★ [Line 161:13] "_accrued_cash" is not accessed (Pyright)

tools.py:
  ★ [Line 82:28] "_args" is not accessed (Pyright)
</new-diagnostics>

Root Cause

Pyright's LSP server sends two layers of information:

  1. Standard diagnostics (error/warning/information severity): The _ prefix exemption works correctly — nothing emitted.
  2. Hint diagnostics with DiagnosticTag.Unnecessary (severity = 4 / Hint): Below-threshold cosmetic tags for editor rendering (graying out unused code). Not shown in Problems panels, not counted by CLI.

The Claude Code plugin treats both layers identically, promoting hint-level tags into <new-diagnostics> conversation injections.

Verification: Same pyright binary (1.1.407), same config. CLI reports 0 diagnostics. The LSP server is pyright-langserver --stdio from the same Nix package.

Impact

  • Context waste: Every Read/Edit/Write on an affected file gets ~5-10 lines of false-positive diagnostics injected. Over a refactoring session touching many files, this adds up to hundreds of wasted context tokens.
  • Model distraction: Claude attempts to "fix" non-issues (renaming _args, restructuring tuple unpacking), which wastes turns and can introduce regressions.
  • Undermines trust: After enough false positives, users learn to ignore all LSP diagnostics, defeating the purpose.

Suggested Fix

Filter diagnostics before injecting into conversation context:

  • Exclude severity = DiagnosticSeverity.Hint (value 4)
  • Exclude diagnostics tagged with DiagnosticTag.Unnecessary (value 1)
  • Or make the minimum severity configurable (default: Information or Warning)

Workaround

Disable the plugin: "pyright-lsp@claude-plugins-official": false in settings.json.

Environment

  • Claude Code: latest (2026-02-18)
  • Pyright: 1.1.407 (NixOS)
  • Plugin: pyright-lsp v1.0.0
  • OS: NixOS Linux 6.12.68

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗