mirror of
https://github.com/astral-sh/ruff.git
synced 2026-11-21 12:16:15 +08:00
## Summary This does some polishing on the former `uv-metadata` diagnostic: ### Rename It renames the diagnostic from `uv-metadata` to `project-manager`. This is to make it less uv focused (we could support other project managers) and also make it less technical. `uv-metadata` is an implementation detail. For as far as users are concerned, ty failed to run the project manager to set up the Python environment or to load the project metadata. **Before** ``` warning[uv-metadata]: uv 0.12.2 is too old; upgrade `./old-uv` to uv 0.12.3 or newer --> pyproject.toml:1:1 Found 1 diagnostic ``` **After** ``` warning[project-manager]: Failed to load project metadata from uv: Found uv 0.12.2, but uv 0.12.3 or newer is required --> pyproject.toml:1:1 help: Upgrade `./old-uv` to uv 0.12.3 or newer Found 1 diagnostic ``` ### Setting subdiagnostic We now also attach a sub diagnostic that explains why ty uses the project manager when ty failed to find a supported uv version. This will become more important once we make the uv integration for scripts opt out. **Before** ``` error[uv-metadata]: Failed to invoke `uv workspace metadata`: failed to resolve uv executable: cannot find binary path --> script.py:2:1 Found 1 diagnostic ``` **After** ``` error[project-manager]: Setting up the Python environment with uv failed: could not find `uv` on `PATH` --> script.py:2:1 info: ty uses uv to install this script's dependencies because `project-manager.script` is set to `"uv"` --> script.py:5:28 | 5 | # project-manager.script = "uv" | ^^^^ configured here info: To install uv, see https://docs.astral.sh/uv/ Found 1 diagnostic ``` ### uv error message I changed how we show uv's error message when it fails to resolve dependencies: **Before** ``` error[uv-metadata]: `uv workspace metadata` failed with `exit status: 1` --> script.py:2:1 info: No solution found when resolving dependencies cause: Because missing-script-dependency was not found in the cache and you require missing-script-dependency==99.0.0, we can conclude that your requirements are unsatisfiable. hint: Packages were unavailable because the network was disabled. When the network is disabled, registry packages may only be read from the cache. Found 1 diagnostic ``` **After** ``` error[project-manager]: Setting up the Python environment with uv failed --> script.py:2:1 error: No solution found when resolving dependencies cause: Because missing-script-dependency was not found in the cache and you require missing-script-dependency==99.0.0, we can conclude that your requirements are unsatisfiable. hint: Packages were unavailable because the network was disabled. When the network is disabled, registry packages may only be read from the cache. error: `uv workspace metadata` exited with status 1 Found 1 diagnostic ``` I don't love it, but formatting this one is a bit tricky, because uv doesn't provide us with structured output and we need to preserve any whitespace as is, to not mess up uv provided code frames. And concise ``` script.py:2:1: error[project-manager] Setting up the Python environment with uv failed: No solution found when resolving dependencies Found 1 diagnostic ``` ## Notes to reviewers Stacked on #30527. Verified the diagnostics in full and concise CLI output and in the language server.
The ty Language Server
ty server implements the Language Server Protocol for ty's editor integrations.
Extensions to the protocol are documented in the ty language server documentation.