Skip to content

Filter only selected Python patch versions in tests - #1188

Draft
zaniebot wants to merge 5 commits into
mainfrom
zb/exact-python-patch-filters-20260909
Draft

zaniebot wants to merge 5 commits into
mainfrom
zb/exact-python-patch-filters-20260909

Conversation

@zaniebot

Copy link
Copy Markdown
Collaborator

TestContext masks every patch number that shares a requested Python minor version, which can hide literal interpreter requests, package versions, and Python constraints in snapshots. Retain the interpreter version already found during setup and mask only its selected patch unless an exact patch was requested. Restore the unrelated version literals in the affected snapshots.

Refs astral-sh#14008.

@astral-automations-bot astral-automations-bot Bot added internal A refactor or improvement that is not user-facing internal:testing Internal testing of behavior labels Sep 10, 2026
@zaniebot
zaniebot force-pushed the zb/exact-python-patch-filters-20260909 branch from b46cbce to c5b0afd Compare September 10, 2026 02:39
@zaniebot zaniebot added priority:4 Low: worthwhile tests, refactors, or maintenance with modest immediate benefit. size:2 Moderate: one subsystem with meaningful invariants, edge cases, or operational evidence to inspect. risk:2 Low, contained risk of minor incorrect behavior with straightforward recovery. labels Sep 10, 2026
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/exact-python-patch-filters-20260909 branch from c5b0afd to 1d60fbe Compare September 30, 2026 02:14
@codspeed

codspeed Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 8 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 54 untouched benchmarks
⏩ 35 skipped benchmarks1


Comparing zb/exact-python-patch-filters-20260909 (8c8d91f) with main (06bf2e8)2

Open in CodSpeed

Footnotes

  1. 35 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (4f14d44) during the generation of this report, so 06bf2e8 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@zaniebot zaniebot added the project:maintainer-followups Maintainer follow-up work label Oct 9, 2026
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/exact-python-patch-filters-20260909 branch from 1d60fbe to a54c91c Compare October 9, 2026 19:27
Comment thread crates/uv-test/src/lib.rs
Comment on lines +1062 to +1063
if let Some(filter) = python_patch_version_filter(version, actual_version) {
filters.push(filter);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Refresh the remaining snapshots affected by the filter

With Python 3.12.9 from .python-versions, this filter leaves 3.12.1 and 3.12.0 intact, but two snapshots still expect them masked. lock_group_includes_requires_python retains blargh = ">=3.12.[X],>=3.13" at crates/uv/tests/lock/lock.rs:33465. The it__ecosystem__semantic-kernel-lock-file.snap snapshot also retains 3.12.[X] in the google-cloud-storage version and its two artifact URLs. Both tests will consequently fail their snapshot assertions. Update these remaining literals to 3.12.1 and 3.12.0, respectively.

@zaniebot
zaniebot deployed to automations October 9, 2026 20:16 — with GitHub Actions Active
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/exact-python-patch-filters-20260909 branch from 43c3a05 to efc1cd6 Compare October 10, 2026 02:53
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/exact-python-patch-filters-20260909 branch from efc1cd6 to 8c32dfe Compare October 13, 2026 17:31
Comment thread crates/uv-test/src/lib.rs
Comment on lines +1073 to +1074
if let Some(filter) = python_patch_version_filter(version, actual_version) {
filters.push(filter);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Create the test venv from the interpreter used by the filter

The discovered interpreter is not necessarily the one used by TestContext::create_venv(), which independently calls get_python(). For example, with an active base Conda interpreter at 3.12.7 and a managed installation at 3.12.9, discovery selects Conda while get_python() selects the managed installation. This filter then masks only 3.12.7, leaving the venv’s 3.12.9 visible and breaking snapshots such as pip_check::check_python_version. The previous filter masked both patches. Reuse the saved executable when creating or resetting the venv so interpreter selection and snapshot filtering agree.

@zaniebot
zaniebot deployed to automations October 13, 2026 18:00 — with GitHub Actions Active
@zaniebot
zaniebot deployed to automations October 13, 2026 18:13 — with GitHub Actions Active
@zaniebot
zaniebot deployed to automations October 13, 2026 18:18 — with GitHub Actions Active
Comment thread crates/uv-python-managed/src/managed.rs Outdated
Comment on lines +1436 to +1441
let v3_1 = PythonVersion::from_str("3.1").unwrap();
let matched: Vec<_> = installations.find_version(&v3_1).unwrap().collect();
let request = VersionRequest::from(&v3_1);
let matched: Vec<_> = installations
.iter()
.filter(|installation| request.matches_installation_key(installation.key()))
.collect();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Move the retained version-matching test to its owning layer

With find_version removed, this test reconstructs its filtering locally. Production discovery uses VersionRequest::matches_version, while matches_installation_key now has only these test callers. The temporary installation tree, host-platform detection, and process-global environment mutation therefore no longer exercise the production version-selection path. Move the 3.1 versus 3.10 regression into the existing VersionRequest tests, exercising the production matcher directly, and remove this obsolete filesystem-based reconstruction.

@zaniebot
zaniebot deployed to automations October 13, 2026 18:32 — with GitHub Actions Active
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/exact-python-patch-filters-20260909 branch from 8c8d91f to 677a48a Compare October 19, 2026 14:30
Comment on lines -270 to -271
let request = VersionRequest::try_from(version)
.map_err(|_| Error::InvalidPythonVersion(version.to_string()))?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Remove the error variant left behind by find_version

This was the only construction site of uv_python_managed::Error::InvalidPythonVersion. Removing the helper leaves a public error variant describing a failure the crate no longer produces, making its error API misleading. Remove the variant and its #[error] attribute alongside this method.

This branch was successfully deployed

1 active deployment
automations — 677a48a3 Deployed Oct 19, 2026 by astral-automations-bot[bot] via review-code-quality / report #11043
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal:testing Internal testing of behavior internal A refactor or improvement that is not user-facing priority:4 Low: worthwhile tests, refactors, or maintenance with modest immediate benefit. project:maintainer-followups Maintainer follow-up work risk:2 Low, contained risk of minor incorrect behavior with straightforward recovery. size:2 Moderate: one subsystem with meaningful invariants, edge cases, or operational evidence to inspect.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants