Skip to content

Consolidate Python discovery strategies - #19775

Merged
zanieb merged 2 commits into
mainfrom
zb/refactor-python-discovery
Jun 10, 2026
Merged

Consolidate Python discovery strategies#19775
zanieb merged 2 commits into
mainfrom
zb/refactor-python-discovery

Conversation

@zanieb

@zanieb zanieb commented Jun 10, 2026

Copy link
Copy Markdown
Member

Summary

Consolidate the sequential and parallel Python discovery paths introduced in #18684.

Both modes now share a single PythonRequest dispatcher and executable-to-installation pipeline. A private QueryStrategy selects either lazy sequential querying or eager parallel querying while preserving the existing filtering, ordering, and error-handling behavior.

No prefetching is introduced here. Sequential discovery still defers reading and traversing PATH, advances candidate executables one at a time, and stops querying after finding an acceptable installation. The pre-existing eager behavior for explicit file, directory, and executable-name requests is unchanged.

Test Plan

  • Added parity coverage across every PythonRequest variant, using independent caches and out-of-order query completion to verify ordered results and non-critical error handling.
  • Added regression coverage proving sequential strategy construction pulls no candidates, one iteration pulls exactly one candidate, later PATH directories are not inspected early, and later interpreters are not queried after a match.
  • Mutation-checked the laziness tests against candidate collection, eager interpreter querying, and eager PATH directory filtering.
  • cargo test -p uv-python
  • cargo test -p uv --test python python_list --no-fail-fast
  • cargo test -p uv --test python python_find --no-fail-fast
  • cargo +stable clippy -p uv-python --tests --no-deps --locked -- -D warnings
  • cargo +stable fmt --all -- --check

@zanieb
zanieb force-pushed the zb/python-list-explicit-path-errors branch from f05c06a to e601034 Compare June 10, 2026 21:45
@zanieb
zanieb force-pushed the zb/refactor-python-discovery branch from d3762cc to 9f43020 Compare June 10, 2026 21:46
@zanieb
zanieb force-pushed the zb/python-list-explicit-path-errors branch from e601034 to e9d833c Compare June 10, 2026 21:48
@zanieb
zanieb force-pushed the zb/refactor-python-discovery branch from 9f43020 to 29849e4 Compare June 10, 2026 21:49
Base automatically changed from zb/python-list-explicit-path-errors to main June 10, 2026 21:54
@zanieb
zanieb force-pushed the zb/refactor-python-discovery branch from d6536e5 to c500660 Compare June 10, 2026 22:02
@zanieb
zanieb force-pushed the zb/refactor-python-discovery branch from c500660 to 47c52db Compare June 10, 2026 22:09
@astral-sh-bot

astral-sh-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

uv test inventory changes

This PR changes the tests when compared with the latest main baseline.

  • Added tests: 4
  • Removed tests: 0
  • Changed suites: 1
uv-python: +4 / -0

Added:

  • uv-python::discovery::tests::sequential_query_strategy_does_not_prefetch_executables
  • uv-python::tests::find_all_python_installations_matches_sequential_discovery
  • uv-python::tests::find_python_installation_queries_lazily
  • uv-python::tests::find_python_installations_discovers_search_path_lazily

Removed: none

@zanieb zanieb added the internal A refactor or improvement that is not user-facing label Jun 10, 2026
@zanieb
zanieb marked this pull request as ready for review June 10, 2026 22:59
@zanieb
zanieb merged commit ea6de30 into main Jun 10, 2026
108 of 110 checks passed
@zanieb
zanieb deleted the zb/refactor-python-discovery branch June 10, 2026 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user-facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant