Skip to content

Commit f8472d4

Browse files
fix(workstream-c): address CodeRabbit review - list validation and label sentinel fix
1 parent f91b995 commit f8472d4

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

application/tests/test_cheatsheet_categorizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _make_record(
4444
source_id=source_id,
4545
title=title,
4646
hyperlink=f"{base}/{source_id}.html",
47-
summary="",
47+
summary="Test summary",
4848
headings=headings or [],
4949
raw_markdown_path=f"cheatsheets/{source_id}.md",
5050
category_hints=category_hints or [],

application/utils/external_project_parsers/parsers/cheatsheet_categorizer.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,15 @@ def __post_init__(self) -> None:
208208
f"CheatsheetRecord.{fname} must be a non-empty string, "
209209
f"got {value!r}"
210210
)
211+
for fname in ("headings", "category_hints"):
212+
value = getattr(self, fname)
213+
if not isinstance(value, list) or not all(
214+
isinstance(item, str) for item in value
215+
):
216+
raise ValueError(
217+
f"CheatsheetRecord.{fname} must be a list of strings, "
218+
f"got {value!r}"
219+
)
211220

212221

213222
# ---------------------------------------------------------------------------
@@ -368,6 +377,7 @@ def _validate_labels(labels) -> List[str]:
368377
369378
Returns an empty list if nothing valid remains; the caller should
370379
fall back to deterministic categorisation in that case.
380+
UNCATEGORIZED is stripped if other real labels are present.
371381
"""
372382
if not isinstance(labels, list):
373383
return []
@@ -378,4 +388,5 @@ def _validate_labels(labels) -> List[str]:
378388
if lbl not in seen:
379389
deduped.append(lbl)
380390
seen.add(lbl)
381-
return deduped
391+
real = [lbl for lbl in deduped if lbl != UNCATEGORIZED]
392+
return real if real else deduped

0 commit comments

Comments
 (0)