feat(python): rework python.uv_venv_auto setting#7905
Conversation
Summary of ChangesHello @halms, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines how Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively introduces the python.uv_venv_auto_source setting to only source existing uv virtual environments, and correctly deprecates the old python.uv_venv_auto setting. The logic is sound, and the changes across documentation, tests, and schema are consistent. The move to guide users towards mise prep for venv creation is a good one. I have one suggestion to enhance the warning messages for a better user experience when a venv is missing.
There was a problem hiding this comment.
Pull request overview
Adds a new setting to auto-source existing uv virtual environments (without creating them) and deprecates the previous auto-create behavior, aligning with the new prepare workflow.
Changes:
- Add
python.uv_venv_auto_sourceand deprecatepython.uv_venv_auto. - Update uv venv integration to only load an existing
.venv(and emit guidance when missing). - Update schema/docs and adjust e2e tests to cover the new behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/uv.rs |
Switches from “create or load” to “load only”, adds deprecation + missing-venv guidance, and checks for [prepare.uv]. |
settings.toml |
Marks python.uv_venv_auto deprecated and introduces python.uv_venv_auto_source. |
schema/mise.json |
Updates JSON schema for deprecation and new setting. |
e2e/core/test_python_uv_venv_x_tiny |
Uses the new setting and ensures a .venv exists for the test via uv venv. |
e2e/core/test_python_uv_venv |
Updates commented example to the new setting name. |
e2e-win/uv.Tests.ps1 |
Switches Windows e2e to python.uv_venv_auto_source. |
docs/mise-cookbook/python.md |
Updates docs to recommend the new setting and explain prepare.uv + mise prep flow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cffb0a1 to
d830ce1
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d830ce1 to
f5928c2
Compare
python.uv_venv_auto setting
f5928c2 to
8cb3936
Compare
|
/gemini review |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request effectively reworks the python.uv_venv_auto setting, introducing more granular control over virtual environment handling with uv. The changes are well-structured, with significant refactoring to improve modularity, such as extracting venv creation logic. The updates to documentation, tests, and schemas are comprehensive and align with the new functionality.
I've identified a couple of areas for improvement. One is a potential discrepancy between the implemented behavior and the description for the legacy true value of python.uv_venv_auto. Another is a suggestion to further refactor a large function to improve maintainability. Overall, this is a great enhancement.
7a4f6fb to
469bc42
Compare
|
/gemini review |
| ListPath: "string[]", | ||
| SetString: "string[]", | ||
| "IndexMap<String, String>": "object", | ||
| BoolOrString: ["boolean", "string"], |
There was a problem hiding this comment.
if this ends up being too much of a pain we could have a replacement env var maybe. That said, I've needed this before so it will come in handy in the future I'm sure.
There was a problem hiding this comment.
It took a bit of back and forth, but I think I got it now.
Also tried allowing the type description in settings.toml already being an array, like
type = ["Boolean", "String"]But that led to more complications, so I went with the predefined type instead.
7b6a3c8 to
34a4435
Compare
34a4435 to
eaad0de
Compare
|
/gemini review |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request is a well-executed feature enhancement that reworks the python.uv_venv_auto setting for better flexibility and usability with uv. The introduction of new string-based options ("source", "create|source") and the deprecation of the legacy boolean true value are clear improvements. The refactoring of venv creation logic into a shared, centralized function in src/config/env_directive/venv.rs significantly improves code structure and maintainability. The changes are consistently applied across the codebase, including configuration, schemas, documentation, and tests. I've noted a couple of minor maintainability improvements in the build script to make it more robust for future changes. Overall, this is an excellent contribution.
0243954 to
8c386ff
Compare
|
bugbot run |
|
I think you need to handle "true" so MISE_PYTHON_UV_VENV_AUTO=true works correctly too |
- add new BooleanOrString type - enable more flexible definition of enum values/descriptions
Introduce new options for python.uv_venv_auto: `"source"`, `"create|source"` and deprecate (in the future) `true`. `false` remains the same. Factorize venv code between `uv.rs` and `venv.rs`.
8c386ff to
10daaaf
Compare
Should be fixed now. I've copied what |
10daaaf to
356916f
Compare
### 🚀 Features - **(asset-matcher)** enable `mingw-w64` detection for windows packages by @lchagnoleau in [#7981](#7981) - **(crates/vfox)** add download_path to BackendInstall context by @malept in [#7959](#7959) - **(python)** rework `python.uv_venv_auto` setting by @halms in [#7905](#7905) - add "Did you mean?" suggestions and inactive tool warnings by @jdx in [#7965](#7965) ### 🐛 Bug Fixes - **(hook-env)** skip remote version fetching for uninstalled tools in prefer-offline mode by @jdx in [#7976](#7976) - **(install.sh)** Corret `setup` to `set up` by @gogolok in [#7980](#7980) - retry spawn on ETXTBSY (Text file busy) by @jdx in [#7964](#7964) - improve ToolOptions parsing to support comma separated values by @roele in [#7971](#7971) ### 📚 Documentation - improve plugin documentation with comparisons and template links by @jdx in [#7962](#7962) ### 📦️ Dependency Updates - bump hyper-util, system-configuration, lru, aws-sdk, and others by @jdx in [#7977](#7977) ### Chore - **(vfox)** add LuaCATS type definitions for plugin IDE support by @jdx in [#7961](#7961) - **(vfox)** add `download_path` to `BackendInstallCtx` type defintion by @malept in [#7973](#7973) - add stylua linting for vfox plugin Lua files by @jdx in [#7960](#7960) - use system Rust for PPA builds on Ubuntu 26.04+ by @jdx in [#7956](#7956) ### New Contributors - @gogolok made their first contribution in [#7980](#7980) ## 📦 Aqua Registry Updates #### New Packages (4) - [`autobrr/mkbrr`](https://github.com/autobrr/mkbrr) - [`dodobrands/Peekie`](https://github.com/dodobrands/Peekie) - [`grpc/grpc-java/protoc-gen-grpc-java`](https://github.com/grpc/grpc-java/protoc-gen-grpc-java) - [`str4d/age-plugin-yubikey`](https://github.com/str4d/age-plugin-yubikey) #### Updated Packages (3) - [`biomejs/biome`](https://github.com/biomejs/biome) - [`rust-cross/cargo-zigbuild`](https://github.com/rust-cross/cargo-zigbuild) - [`siderolabs/talos`](https://github.com/siderolabs/talos)
The value 'true' is deprecated, and setting it to 'source' prevents some issues highlighted in jdx/mise#7905
## Context With the current `python.uv_venv_auto` behavior, there are two annoying things: 1. it always creates venvs if they not exist This is not needed for `uv`, since that usually creates/updates it's venvs transparently (when doing `uv run` or `uv sync`, ...). And it breaks `mise prepare` for `uv` since it creates the `.venv` folder but does not install any deps. So `mise prepare` thinks everything is up-to-date when it isn't. (the uv-native venv creation appears to not have been covered by jdx#7770) 2. it exports the mise python version to the env var `UV_PYTHON`, which forces uv to use that _version_. ## Changes - Upfront, some reworking of the schema of `settings.toml`, specifically the `type` and `enum` definitions. Added the `BooleanOrString` type needed for this and also made the `enum` definitions more flexible (e.g. with mixed types) - Introducing new values for `python.uv_venv_auto` - `"source"` only sources existing venvs - `"create|source"` creates if not exists and sources venvs (but does not set UV_PYTHON anymore) - `false` does nothing – like now - `true` (legacy, will be deprecated in 6 months) – like now, also sets UV_PYTHON - Unified the code creating/sourcing venvs between `settings.python.uv_venv_auto` and `env._.python.venv`, which should now also mark these as stale at creation. I think with this changes, `python.uv_venv_auto` becomes much more useful.
### 🚀 Features - **(asset-matcher)** enable `mingw-w64` detection for windows packages by @lchagnoleau in [jdx#7981](jdx#7981) - **(crates/vfox)** add download_path to BackendInstall context by @malept in [jdx#7959](jdx#7959) - **(python)** rework `python.uv_venv_auto` setting by @halms in [jdx#7905](jdx#7905) - add "Did you mean?" suggestions and inactive tool warnings by @jdx in [jdx#7965](jdx#7965) ### 🐛 Bug Fixes - **(hook-env)** skip remote version fetching for uninstalled tools in prefer-offline mode by @jdx in [jdx#7976](jdx#7976) - **(install.sh)** Corret `setup` to `set up` by @gogolok in [jdx#7980](jdx#7980) - retry spawn on ETXTBSY (Text file busy) by @jdx in [jdx#7964](jdx#7964) - improve ToolOptions parsing to support comma separated values by @roele in [jdx#7971](jdx#7971) ### 📚 Documentation - improve plugin documentation with comparisons and template links by @jdx in [jdx#7962](jdx#7962) ### 📦️ Dependency Updates - bump hyper-util, system-configuration, lru, aws-sdk, and others by @jdx in [jdx#7977](jdx#7977) ### Chore - **(vfox)** add LuaCATS type definitions for plugin IDE support by @jdx in [jdx#7961](jdx#7961) - **(vfox)** add `download_path` to `BackendInstallCtx` type defintion by @malept in [jdx#7973](jdx#7973) - add stylua linting for vfox plugin Lua files by @jdx in [jdx#7960](jdx#7960) - use system Rust for PPA builds on Ubuntu 26.04+ by @jdx in [jdx#7956](jdx#7956) ### New Contributors - @gogolok made their first contribution in [jdx#7980](jdx#7980) ## 📦 Aqua Registry Updates #### New Packages (4) - [`autobrr/mkbrr`](https://github.com/autobrr/mkbrr) - [`dodobrands/Peekie`](https://github.com/dodobrands/Peekie) - [`grpc/grpc-java/protoc-gen-grpc-java`](https://github.com/grpc/grpc-java/protoc-gen-grpc-java) - [`str4d/age-plugin-yubikey`](https://github.com/str4d/age-plugin-yubikey) #### Updated Packages (3) - [`biomejs/biome`](https://github.com/biomejs/biome) - [`rust-cross/cargo-zigbuild`](https://github.com/rust-cross/cargo-zigbuild) - [`siderolabs/talos`](https://github.com/siderolabs/talos)
Context
With the current
python.uv_venv_autobehavior, there are two annoying things:This is not needed for
uv, since that usually creates/updates it's venvs transparently (when doinguv runoruv sync, ...).And it breaks
mise prepareforuvsince it creates the.venvfolder but does not install any deps. Somise preparethinks everything is up-to-date when it isn't. (the uv-native venv creation appears to not have been covered by fix(prepare): handle freshness check for auto-created venvs #7770)UV_PYTHON, which forces uv to use that version.Changes
settings.toml, specifically thetypeandenumdefinitions.Added the
BooleanOrStringtype needed for this and also made theenumdefinitions more flexible (e.g. with mixed types)python.uv_venv_auto"source"only sources existing venvs"create|source"creates if not exists and sources venvs (but does not set UV_PYTHON anymore)falsedoes nothing – like nowtrue(legacy, will be deprecated in 6 months) – like now, also sets UV_PYTHONsettings.python.uv_venv_autoandenv._.python.venv, which should now also mark these as stale at creation.I think with this changes,
python.uv_venv_autobecomes much more useful.