Skip to content

Commit

Permalink
pep723: Fix empty metadata lines throwing "Invalid metadata line: #"
Browse files Browse the repository at this point in the history
  • Loading branch information
adisbladis committed Jan 30, 2025
1 parent 78ea10a commit 0d9f4b9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pep723.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let
stripComment =
l:
let
m = match " *# (.+)" l;
m = match " *# ?(.*)" l;
in
if match " *" l != null then
l
Expand Down
28 changes: 28 additions & 0 deletions lib/test_pep723.nix
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,34 @@ in
};
};

testEmptyLine = {
expr =
(pep723.parseScript ''
# /// script
# requires-python = ">=3.11"
# # Note: Empty line below
#
# ///
'').requires-python;
expected = [
{
op = ">=";
version = {
dev = null;
epoch = 0;
local = null;
post = null;
pre = null;
release = [
3
11
];
str = "3.11";
};
}
];
};

# Note the empty line in the script.
testHolyMetadata = {
expr = pep723.parseScript ''
Expand Down

0 comments on commit 0d9f4b9

Please sign in to comment.