Strip environment markers from detected uv dependency pins (#938)

## Summary
- strip PEP 508 environment markers before extracting uv versions from
dependency entries
- cover dependency-group pins with and without whitespace before the
marker
- cover requirements-style pins with markers

Fixes #920

## Validation
- npm ci --ignore-scripts
- npm run all

Refs: pi-session 019f316a-4108-7975-892f-ee5bf8abc7c3
This commit is contained in:
Kevin Stillhammer
2026-07-05 10:47:17 +02:00
committed by GitHub
parent 17c398959b
commit d31148d669
3 changed files with 37 additions and 4 deletions

View File

@@ -63,7 +63,11 @@ function getUvVersionFromAllDependencies(
allDependencies: string[],
): string | undefined {
return allDependencies
.find((dep: string) => dep.match(/^uv[=<>~!]/))
?.match(/^uv([=<>~!]+\S*)/)?.[1]
.trim();
.map(getUvVersionFromDependency)
.find((version): version is string => version !== undefined);
}
function getUvVersionFromDependency(dependency: string): string | undefined {
const dependencyWithoutMarker = dependency.split(";", 1)[0]?.trim();
return dependencyWithoutMarker?.match(/^uv([=<>~!]+\S*)/)?.[1].trim();
}