Skip to content

Commit

Permalink
pep440: Remove internal function stripDash
Browse files Browse the repository at this point in the history
We can just tack on the stripiing to the input regex.
  • Loading branch information
adisbladis committed Mar 2, 2024
1 parent 8b0827b commit ea6be51
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions lib/pep440.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ let
post = 3;
};

# Strip leading dash from a string
stripDash = s:
let
m = match "(-)(.+)" s;
in
if m != null then (elemAt m 1) else s;

# Compare dev/pre/post/local release modifiers
compareVersionModifier = x: y: assert x != null && y != null; let
prioX = modifierPriority.${x.type};
Expand Down Expand Up @@ -124,11 +117,11 @@ fix (self: {
(mod:
let
# Split post345 into ["post" "345"]
m = match "([^0-9]+)([0-9]+)" mod;
m = match "-?([^0-9]+)([0-9]+)" mod;
mAt = elemAt m;
in
assert m != null; {
type = normalizedReleaseType (stripDash (mAt 0));
type = normalizedReleaseType (mAt 0);
value = toIntRelease (mAt 1);
})
(filter (s: isString s && s != "") (split "\\." modifiersSegment));
Expand Down

0 comments on commit ea6be51

Please sign in to comment.