Skip to content

Respect skip-interpreter-query for client-provided pythonPath in the LSP - #4615

Open
rootkiller6788 wants to merge 1 commit into
facebook:mainfrom
rootkiller6788:fix-lsp-skip-interpreter-query
Open

Respect skip-interpreter-query for client-provided pythonPath in the LSP#4615
rootkiller6788 wants to merge 1 commit into
facebook:mainfrom
rootkiller6788:fix-lsp-skip-interpreter-query

Conversation

@rootkiller6788

Copy link
Copy Markdown

Summary

Fixes #4445: with skip-interpreter-query = true in pyrefly.toml, the LSP still queried the interpreter the client supplied via pythonPath — logging e.g. ERROR Failed to query interpreter at <deleted venv>... and then applying that interpreter on top of the config, defeating the opt-out.

Root cause

PythonInfo::new queried the interpreter eagerly in update_pythonpath, i.e. as soon as the client sent pythonPath, before any config file had been resolved. The skip-interpreter-query flag only lives on the ConfigFile, so it was never consulted. The configurer then applied the pre-queried environment unconditionally (when the config hadn't picked an interpreter).

Fix

  • PythonInfo now stores only the interpreter path; the query is deferred to the point where the workspace config is applied (WorkspaceConfigConfigurer::configure).
  • The client interpreter is applied only when the resolved config has no interpreter selection and has not opted out of queries (skip-interpreter-query).
  • A config with skip-interpreter-query = true now never performs (or pays for) an interpreter query, and the client pythonPath is ignored in favor of the config's own environment settings.

Tests

  • test_skip_interpreter_query_ignores_lsp_pythonpath (unix-gated LSP interaction test): opens a project whose config sets skip-interpreter-query = true, verifies an unresolved import stays an error even after the client sends a pythonPath that would resolve it.
  • test_skip_interpreter_query_blocks_client_pythonpath (cross-platform unit test in workspace.rs): pins that a skip-interpreter-query config ignores a client interpreter while a config silent about interpreters still applies it.

Verified with cargo +1.96.1 test: all LSP interaction tests (1081) and the workspace/configuration modules pass.

When a workspace config sets skip-interpreter-query = true, the LSP should not
query the interpreter. But a client-provided pythonPath was queried eagerly in
PythonInfo::new, before any config was read, and then applied on top of the
config, so the opt-out had no effect and a deleted interpreter produced a
spurious "Failed to query interpreter" error.

Defer the query to the point where the workspace config is applied, and skip
applying the client interpreter entirely when the config opted out of queries.
A config with skip-interpreter-query = true now never performs (or pays for) an
interpreter query.

Adds a regression test for the LSP case and a cross-platform unit test for the
workspace-side logic.
@meta-codesync

meta-codesync Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D116931728. (Because this pull request was imported automatically, there will not be any future comments.)

@rootkiller6788
rootkiller6788 marked this pull request as ready for review August 24, 2026 07:13
@github-actions
github-actions Bot requested a review from NathanTempest August 24, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LSP does not respect skip-interpreter-query = true in VSCode workspace.

2 participants