Skip to content

Commit 92ac70b

Browse files
Sweep core utils/python_{lock,script}.rs (#1990)
* Start sweep of utils/python_{lock,script}.rs Assisted-by: Claude Code:claude-opus-5-5 * Sweep utils/python_lock.rs Delete the dead complete_python_lock_metadata pair and PythonLockProbe: the hosted wheel gate now asks PythonLockSession::plan, which runs the same planner, so the probe-equivalence test goes with it. One names / repoint helper replaces five name checks and four repoint copies, the planner reuses lock_package_collection, and one artifact_filename replaces two copies. python_lock_paths is one iterator chain. The direct-URL test's "ours" case asserted is_ok(), which also passed on Ok(None); it now requires the rewritten lock. The five test modules are one. Bare issue numbers and a banner are gone. Assisted-by: Claude Code:claude-opus-5-5 * Sweep utils/python_script.rs One tool_uv reader replaces three [tool.uv] chains, and one declares_directly replaces the three "is this a direct dependency" copies in hosted_override_pins, wires_through_override and the two metadata rewriters. push_hosted_override is inlined into its one caller and is_hosted_override is private. refuse_uv_no_sources / refuse_uv_no_binary lose their script parameter: every caller passed None (scripts use the *_script_* variants). The SourcesLayout doc is trimmed to its why, bare issue numbers are gone, and a unit test now covers no-binary's combine rules. Assisted-by: Claude Code:claude-opus-5-5 * Tighten review findings in the python sweep The direct-URL test's "ours" case now requires the artifact digest to replace the fixture's, since the input already held the URL. Rename rewrite_project_metadata's local that shadowed tool_uv, and keep the SourcesLayout caveat about transitive override reverts. Assisted-by: Claude Code:claude-opus-5-5 --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 318193c commit 92ac70b

5 files changed

Lines changed: 226 additions & 531 deletions

File tree

‎crates/socket-patch-core/src/hosted/engine.rs‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,8 +1345,8 @@ pub fn wheel_targets<'a>(
13451345
candidates: &'a [Candidate],
13461346
files: &BTreeMap<String, String>,
13471347
) -> Vec<(&'a DepOverride, &'a str)> {
1348-
use crate::utils::python_lock::{ArtifactSource, PythonLockProbe};
1349-
let mut probes: Option<Vec<PythonLockProbe>> = None;
1348+
use crate::utils::python_lock::{ArtifactSource, PythonLockSession};
1349+
let mut probes: Option<Vec<(&str, PythonLockSession)>> = None;
13501350
let mut out = Vec::new();
13511351
for dep in candidates
13521352
.iter()
@@ -1371,15 +1371,19 @@ pub fn wheel_targets<'a>(
13711371
.filter(|(path, _)| {
13721372
*path == "uv.lock" || crate::utils::python_lock::is_script_lock_name(path)
13731373
})
1374-
.map(|(_, text)| PythonLockProbe::new(text))
1374+
.map(|(_, text)| (text.as_str(), PythonLockSession::new(text)))
13751375
.collect()
13761376
})
13771377
.iter()
1378-
.any(|probe| {
1379-
probe.rewrites(
1380-
&dep.name,
1381-
&dep.version,
1382-
ArtifactSource::Url(&dep.artifact_url),
1378+
.any(|(text, session)| {
1379+
matches!(
1380+
session.plan(
1381+
text,
1382+
&dep.name,
1383+
&dep.version,
1384+
ArtifactSource::Url(&dep.artifact_url),
1385+
),
1386+
Ok(Some(_))
13831387
)
13841388
});
13851389
if native_target {

‎crates/socket-patch-core/src/patch/redirect/mod.rs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6576,14 +6576,12 @@ fn plan_python_metadata_with(
65766576
} else {
65776577
crate::utils::python_script::refuse_uv_no_sources(
65786578
&dep.name,
6579-
None,
65806579
Some(&original),
65816580
project_file(crate::utils::python_script::UV_TOML),
65826581
)
65836582
.and_then(|()| {
65846583
crate::utils::python_script::refuse_uv_no_binary(
65856584
&dep.name,
6586-
None,
65876585
Some(&original),
65886586
project_file(crate::utils::python_script::UV_TOML),
65896587
)

0 commit comments

Comments
 (0)