Skip to content

Commit a56e521

Browse files
authored
uv-resolver: use disjointness checks instead of marker equality (#8661)
When this code was written, we didn't have "proper" disjointness checks, and so simple equality was used instead. Arguably disjointness checks are more correct, and this would also simplify some case analysis in an ongoing refactor.
1 parent c335dc5 commit a56e521

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

crates/uv-resolver/src/candidate_selector.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,15 @@ impl CandidateSelector {
178178
let preferences_match =
179179
preferences.get(package_name).filter(|(marker, _version)| {
180180
// `.unwrap_or(true)` because the universal marker is considered matching.
181-
marker.map(|marker| marker == fork_markers).unwrap_or(true)
181+
marker
182+
.map(|marker| !marker.is_disjoint(fork_markers))
183+
.unwrap_or(true)
182184
});
183185
let preferences_mismatch =
184186
preferences.get(package_name).filter(|(marker, _version)| {
185-
marker.map(|marker| marker != fork_markers).unwrap_or(false)
187+
marker
188+
.map(|marker| marker.is_disjoint(fork_markers))
189+
.unwrap_or(false)
186190
});
187191
self.get_preferred_from_iter(
188192
preferences_match.chain(preferences_mismatch),

crates/uv/tests/it/edit.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,15 +2936,11 @@ fn add_update_marker() -> Result<()> {
29362936
----- stdout -----
29372937
29382938
----- stderr -----
2939-
Resolved 8 packages in [TIME]
2940-
Prepared 3 packages in [TIME]
2941-
Uninstalled 3 packages in [TIME]
2942-
Installed 3 packages in [TIME]
2943-
- idna==3.6
2944-
+ idna==2.7
2939+
Resolved 10 packages in [TIME]
2940+
Prepared 1 package in [TIME]
2941+
Uninstalled 1 package in [TIME]
2942+
Installed 1 package in [TIME]
29452943
~ project==0.1.0 (from file://[TEMP_DIR]/)
2946-
- urllib3==2.2.1
2947-
+ urllib3==1.23
29482944
"###);
29492945

29502946
let pyproject_toml = context.read("pyproject.toml");
@@ -2979,7 +2975,7 @@ fn add_update_marker() -> Result<()> {
29792975
----- stdout -----
29802976
29812977
----- stderr -----
2982-
Resolved 8 packages in [TIME]
2978+
Resolved 10 packages in [TIME]
29832979
Prepared 1 package in [TIME]
29842980
Uninstalled 1 package in [TIME]
29852981
Installed 1 package in [TIME]
@@ -3026,10 +3022,10 @@ fn add_update_marker() -> Result<()> {
30263022
Installed 1 package in [TIME]
30273023
- certifi==2024.2.2
30283024
- charset-normalizer==3.3.2
3029-
- idna==2.7
3025+
- idna==3.6
30303026
~ project==0.1.0 (from file://[TEMP_DIR]/)
30313027
- requests==2.31.0
3032-
- urllib3==1.23
3028+
- urllib3==2.2.1
30333029
"###);
30343030

30353031
let pyproject_toml = context.read("pyproject.toml");

0 commit comments

Comments
 (0)