Skip to content

Commit

Permalink
fix(pep621): pep508 version spec with parens (#33632)
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 authored Jan 17, 2025
1 parent 1d64a10 commit 846c867
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/modules/manager/pep621/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ describe('modules/manager/pep621/utils', () => {
${null} | ${false} | ${undefined} | ${undefined} | ${undefined} | ${undefined}
${'blinker'} | ${true} | ${'blinker'} | ${undefined} | ${undefined} | ${undefined}
${'packaging==20.0.0'} | ${true} | ${'packaging'} | ${'==20.0.0'} | ${undefined} | ${undefined}
${'packaging (==20.0.0)'} | ${true} | ${'packaging'} | ${'==20.0.0'} | ${undefined} | ${undefined}
${'packaging (==20.0.0); python_version < "3.8"'} | ${true} | ${'packaging'} | ${'==20.0.0'} | ${undefined} | ${'python_version < "3.8"'}
${'packaging>=20.9,!=22.0'} | ${true} | ${'packaging'} | ${'>=20.9,!=22.0'} | ${undefined} | ${undefined}
${'cachecontrol[filecache]>=0.12.11'} | ${true} | ${'cachecontrol'} | ${'>=0.12.11'} | ${['filecache']} | ${undefined}
${'private-depB[extra1, extra2]~=2.4'} | ${true} | ${'private-depB'} | ${'~=2.4'} | ${['extra1', 'extra2']} | ${undefined}
Expand Down
10 changes: 9 additions & 1 deletion lib/modules/manager/pep621/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,16 @@ export function parsePEP508(
packageName: regExpExec.groups.packageName,
};
if (is.nonEmptyString(regExpExec.groups.currentValue)) {
result.currentValue = regExpExec.groups.currentValue;
if (
regExpExec.groups.currentValue.startsWith('(') &&
regExpExec.groups.currentValue.endsWith(')')
) {
result.currentValue = regExpExec.groups.currentValue.slice(1, -1).trim();
} else {
result.currentValue = regExpExec.groups.currentValue;
}
}

if (is.nonEmptyString(regExpExec.groups.marker)) {
result.marker = regExpExec.groups.marker;
}
Expand Down

0 comments on commit 846c867

Please sign in to comment.