Skip to content

Commit 810fb54

Browse files
committed
fix: accept empty str to str_to_raw_id() (#23)
1 parent 4a23832 commit 810fb54

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/comfy_script/astutil.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def is_xid_continue(s: str) -> bool:
2424

2525
def str_to_raw_id(s: str) -> str:
2626
s = s.lstrip()
27-
assert s != ''
27+
if s == '':
28+
return '_'
2829

2930
if s.isascii():
3031
s = re.sub(r'[^A-Za-z_0-9]', '_', s)

tests/test_astutil.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import comfy_script.astutil as astutil
55

66
@pytest.mark.parametrize('s, id', [
7+
('', '_'),
78
(':<', '_'),
89
(':|', '_'),
910
(':/', '_'),

0 commit comments

Comments
 (0)