Repository navigation
Commit a0bf90c
## Summary
`uv venv` only writes a `prompt` line to `pyvenv.cfg` when `--prompt` is
passed, but `UvVenv::maybe_from_file` treated `prompt` as mandatory. As
a result, ordinary uv-created venvs were misidentified as generic `Venv`
environments. The generic `Venv` locator already treats `prompt` as
optional, so the same `.venv` could be reported with a different
identity by different code paths — the inconsistent identity drives the
consuming extension to repeatedly re-resolve the same environment (the
CPU spin / flickering kernel selector reported in #432 and
microsoft/vscode-jupyter#17377).
## Root cause
In `crates/pet-uv/src/lib.rs`, `maybe_from_file` returned `None` unless
`uv`, `version_info`, **and** `prompt` were all present (`prompt:
prompt?`). The `uv` marker is what actually identifies a uv-managed
venv; `prompt` is optional metadata.
## Changes
- `UvVenv.prompt` is now `Option<String>`; `maybe_from_file` only
requires the `uv` marker and `version_info`.
- Pass the optional prompt straight through to `.name(...)` in all four
builder sites (matches the generic `Venv` locator).
- Trim trailing whitespace on `version_info` for consistency with the
other fields.
- Updated `test_uv_venv_parse_missing_prompt` (now expects
identification to succeed) and added
`test_uv_venv_parse_real_uv_venv_cfg_without_prompt` using a real `uv
venv` cfg.
## Verification
- `cargo test -p pet-uv` — 42 passing.
- `cargo fmt --all` and `cargo clippy -p pet-uv --all-targets -- -D
warnings` clean.
- Manual repro: a real `uv venv` now resolves as `"kind": "Uv"`
(previously `"Venv"`).
> Note: `cargo clippy --all` surfaces pre-existing
`needless_borrows_for_generic_args` errors in `pet-hatch` tests (newer
local clippy than CI pins); unrelated to this change and present on
`main`.
Fixes #432
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 89bf1c0 commit a0bf90c
1 file changed
Lines changed: 41 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
59 | | - | |
| 63 | + | |
60 | 64 | | |
61 | 65 | | |
62 | 66 | | |
| |||
151 | 155 | | |
152 | 156 | | |
153 | 157 | | |
154 | | - | |
| 158 | + | |
155 | 159 | | |
156 | 160 | | |
157 | 161 | | |
| |||
443 | 447 | | |
444 | 448 | | |
445 | 449 | | |
446 | | - | |
| 450 | + | |
447 | 451 | | |
448 | 452 | | |
449 | 453 | | |
| |||
486 | 490 | | |
487 | 491 | | |
488 | 492 | | |
489 | | - | |
| 493 | + | |
490 | 494 | | |
491 | 495 | | |
492 | 496 | | |
| |||
504 | 508 | | |
505 | 509 | | |
506 | 510 | | |
507 | | - | |
| 511 | + | |
508 | 512 | | |
509 | 513 | | |
510 | 514 | | |
| |||
657 | 661 | | |
658 | 662 | | |
659 | 663 | | |
660 | | - | |
| 664 | + | |
661 | 665 | | |
662 | 666 | | |
663 | 667 | | |
| |||
709 | 713 | | |
710 | 714 | | |
711 | 715 | | |
712 | | - | |
713 | | - | |
| 716 | + | |
| 717 | + | |
714 | 718 | | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
715 | 745 | | |
716 | 746 | | |
717 | 747 | | |
| |||
731 | 761 | | |
732 | 762 | | |
733 | 763 | | |
734 | | - | |
| 764 | + | |
735 | 765 | | |
736 | 766 | | |
737 | 767 | | |
| |||
0 commit comments