pyright-lsp plugin promotes hint-level DiagnosticTag.Unnecessary into conversation context
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
- Enable
pyright-lsp@claude-plugins-official - Project uses
typeCheckingMode = "strict"inpyproject.toml - 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()
- 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:
- Standard diagnostics (error/warning/information severity): The
_prefix exemption works correctly — nothing emitted. - 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
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗