[audit] Gate pyrefly vs pyright — prevent dual Python LSP attach#272
[audit] Gate pyrefly vs pyright — prevent dual Python LSP attach#272stanfish06 wants to merge 1 commit into
Conversation
Enables pyrefly when installed, falls back to pyright. Previously both were unconditionally enabled, causing duplicate diagnostics and hover conflicts on machines where both tools are present. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BBEgozMQ7iHP5JETZTGfNi
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe881e47f9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| -- pyrefly seems capable of showing more type issues as far as I can tell | ||
| vim.lsp.enable("pyrefly") | ||
| -- pyrefly seems capable of showing more type issues; prefer it when installed, fall back to pyright | ||
| if vim.fn.executable("pyrefly") == 1 then |
There was a problem hiding this comment.
Do not disable pyright just because pyrefly is installed
When pyrefly is installed globally for one project, this branch disables pyright for every Python buffer, including repos that only have pyrightconfig.json/pyright-specific settings. At the locked nvim-lspconfig rev, pyrefly starts as pyrefly lsp and does not list pyrightconfig.json among its root markers (source), while Pyrefly’s docs say projects without a Pyrefly config fall back to the much smaller basic preset (source); those projects therefore lose the configured pyright diagnostics that worked before. Please make the choice project/config-aware rather than only checking whether the executable exists.
Useful? React with 👍 / 👎.
What
vim.lsp.enable("pyright")andvim.lsp.enable("pyrefly")were both called unconditionally. On any machine where both tools are installed, two Python LSP clients attach to every.pyfile simultaneously.File:
lua/config/plugin_config.lua:102-105Why it matters
When two LSPs attach to the same filetype:
The inline comment already acknowledges pyrefly and pyright are alternatives ("pyrefly seems capable of showing more type issues"), not an intentional dual-server setup.
Change
Prefer pyrefly when installed, fall back to pyright — only one attaches per session:
To switch back to pyright temporarily, either uninstall pyrefly or comment out its branch.
Generated by Claude Code