languages: Fix Python LSP workspace folder detection in uv workspaces#53781
Merged
osiewicz merged 3 commits intozed-industries:mainfrom Apr 20, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #47926
Summary
When using a uv (or Poetry/PDM) workspace with multiple subprojects, Python LSP servers (Pyright, Ruff, ty, etc.) are initialized with the subproject directory as their workspace folder instead of the workspace root. This happens because
PyprojectTomlManifestProvider::search()returns the first (innermost)pyproject.tomlfound walking up the directory tree.For example, in a uv workspace like:
main-project/
├── pyproject.toml # workspace root with [tool.uv.workspace]
├── uv.lock
├── packages/
│ └── project-api/
│ └── pyproject.toml # subpackage
└── projects/
└── project-a/
└── pyproject.toml # subpackage
Opening a file in
packages/project-api/would registerpackages/project-api/as the LSP workspace folder instead ofmain-project/.Approach
The fix uses lockfile existence as a heuristic to detect workspace roots. The updated
search()method walks all ancestors (similar toCargoManifestProvider) and:pyproject.tomlas a fallbackpyproject.tomlthat has a sibling lockfile (uv.lock,poetry.lock,pdm.lock, orPipfile.lock)This works within the existing
ManifestDelegateinterface (existence checks only, no file content reading).pyproject.toml+uv.lock)pyproject.toml+poetry.lock)pyproject.toml, no lockfile)Since the manifest provider is set at the Python language level, this fix applies to all Python LSP servers (Pyright, Ruff, ty, etc.).
Test plan
PyprojectTomlManifestProvidercovering all scenarios abovetest_running_multiple_instances_of_a_single_server_in_one_worktreepasses (independent subprojects without lockfiles)cargo check -p languagescompiles cleanlyRelease Notes: