Skip to content

Commit

Permalink
pep440: Implement parsing of no-op conds
Browse files Browse the repository at this point in the history
Parsing "*" as a no-op.
  • Loading branch information
adisbladis committed Oct 25, 2023
1 parent 29a5cbe commit 28dd42a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/pep440.nix
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fix (self: {
*/
parseVersionCond = cond: (
let
m = match " *([=><!~^]+) *(.+)" cond;
m = match " *([=><!~^]*) *(.+)" cond;
mAt = elemAt m;
in
{
Expand Down Expand Up @@ -256,6 +256,7 @@ fix (self: {
"<" = a: b: self.compareVersions a b < 0;
">" = a: b: self.compareVersions a b > 0;
"===" = throw "Arbitrary equality clause not supported";
"" = _a: _b: true;
};

})
15 changes: 15 additions & 0 deletions lib/test_pep440.nix
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,21 @@ in
};
};
};

testNoOp = {
expr = parseVersionCond "*";
expected = {
op = "";
version = {
dev = null;
epoch = 0;
local = null;
post = null;
pre = null;
release = [ "*" ];
};
};
};
};

comparators = {
Expand Down

0 comments on commit 28dd42a

Please sign in to comment.