Skip to content

Commit c7fd60f

Browse files
committed
pep440.parseVersionConds: Support expressions surrounded by parens
1 parent e14a14d commit c7fd60f

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/pep440.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,13 @@ fix (self: {
271271
}
272272
]
273273
*/
274-
parseVersionConds = conds: map self.parseVersionCond (splitComma conds);
274+
parseVersionConds =
275+
conds:
276+
let
277+
# If the conditions are surrounded by parens strip them away
278+
parenM = match "\\((.+)\\)" conds;
279+
in
280+
map self.parseVersionCond (splitComma (if parenM != null then head parenM else conds));
275281

276282
/*
277283
Compare two versions as parsed by `parseVersion` according to PEP-440.

lib/test_pep440.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ in
353353
};
354354
};
355355

356-
parseVersionConds = {
356+
parseVersionConds = rec {
357357
testSimple = {
358358
expr = parseVersionConds ">=3.0.0rc1,<=4.0";
359359
expected = [
@@ -393,6 +393,11 @@ in
393393
}
394394
];
395395
};
396+
397+
testParen = {
398+
expr = parseVersionConds "(>=3.0.0rc1,<=4.0)";
399+
inherit (testSimple) expected;
400+
};
396401
};
397402

398403
comparators = {

0 commit comments

Comments
 (0)