From 428edbcfe84afbc21e31498a5c2fd99bad5e8305 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 8 Jun 2026 19:00:03 +0000 Subject: [PATCH] Remove bare-value fallback from _extract_labeled The JS always emits {id, label} objects now; the else branch was dead code and the docstring was wrong. Update the remaining test that was still passing bare strings. https://claude.ai/code/session_01EyAJcMoDktLrY9tSbdHViA --- common/components/filters.py | 12 +++--------- tests/test_filters.py | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/common/components/filters.py b/common/components/filters.py index d652427..723d39d 100644 --- a/common/components/filters.py +++ b/common/components/filters.py @@ -62,15 +62,9 @@ def _filter_parse(filter_json: str) -> dict: return {} -def _extract_labeled(items: list) -> list[LabeledOption]: - """Convert a list of bare values or ``{id, label}`` dicts to ``(value, label)`` pairs.""" - result = [] - for item in items: - if isinstance(item, dict): - result.append((str(item.get("id", "")), str(item.get("label", "")))) - else: - result.append((str(item), "")) - return result +def _extract_labeled(items: list[dict]) -> list[LabeledOption]: + """Convert a list of ``{id, label}`` dicts to ``(value, label)`` pairs.""" + return [(str(item["id"]), str(item["label"])) for item in items] def _filter_get_choice(existing: dict, field: str) -> FilterChoice: diff --git a/tests/test_filters.py b/tests/test_filters.py index 5a50d4d..f1af683 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -293,7 +293,7 @@ class TestFilterBarRendering: html = str( FilterBar( filter_json=json.dumps( - {"status": {"value": ["f"], "modifier": "INCLUDES"}} + {"status": {"value": [{"id": "f", "label": "Finished"}], "modifier": "INCLUDES"}} ), ) )