Skip to content

Commit 8110ded

Browse files
Simplify requires-python check in resolver (#9824)
## Summary I believe this is identical.
1 parent 2ca39f1 commit 8110ded

File tree

1 file changed

+21
-33
lines changed
  • crates/uv-resolver/src/resolver

1 file changed

+21
-33
lines changed

crates/uv-resolver/src/resolver/mod.rs

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,43 +1146,31 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
11461146
}
11471147
CompatibleDist::CompatibleWheel { wheel, .. } => wheel.file.requires_python.as_ref(),
11481148
}?;
1149-
if python_requirement.installed() == python_requirement.target() {
1150-
if !python_requirement
1151-
.installed()
1152-
.is_contained_by(requires_python)
1153-
{
1154-
return if matches!(dist, CompatibleDist::CompatibleWheel { .. }) {
1155-
Some(IncompatibleDist::Wheel(IncompatibleWheel::RequiresPython(
1156-
requires_python.clone(),
1157-
PythonRequirementKind::Installed,
1158-
)))
1159-
} else {
1160-
Some(IncompatibleDist::Source(
1161-
IncompatibleSource::RequiresPython(
1162-
requires_python.clone(),
1163-
PythonRequirementKind::Installed,
1164-
),
1165-
))
1166-
};
1167-
}
1149+
if python_requirement.target().is_contained_by(requires_python) {
1150+
None
11681151
} else {
1169-
if !python_requirement.target().is_contained_by(requires_python) {
1170-
return if matches!(dist, CompatibleDist::CompatibleWheel { .. }) {
1171-
Some(IncompatibleDist::Wheel(IncompatibleWheel::RequiresPython(
1152+
if matches!(dist, CompatibleDist::CompatibleWheel { .. }) {
1153+
Some(IncompatibleDist::Wheel(IncompatibleWheel::RequiresPython(
1154+
requires_python.clone(),
1155+
if python_requirement.installed() == python_requirement.target() {
1156+
PythonRequirementKind::Installed
1157+
} else {
1158+
PythonRequirementKind::Target
1159+
},
1160+
)))
1161+
} else {
1162+
Some(IncompatibleDist::Source(
1163+
IncompatibleSource::RequiresPython(
11721164
requires_python.clone(),
1173-
PythonRequirementKind::Target,
1174-
)))
1175-
} else {
1176-
Some(IncompatibleDist::Source(
1177-
IncompatibleSource::RequiresPython(
1178-
requires_python.clone(),
1179-
PythonRequirementKind::Target,
1180-
),
1181-
))
1182-
};
1165+
if python_requirement.installed() == python_requirement.target() {
1166+
PythonRequirementKind::Installed
1167+
} else {
1168+
PythonRequirementKind::Target
1169+
},
1170+
),
1171+
))
11831172
}
11841173
}
1185-
None
11861174
}
11871175

11881176
/// Given a candidate package and version, return its dependencies.

0 commit comments

Comments
 (0)