From 27f546ebc684541a880ad9ce9792e842a25a276d Mon Sep 17 00:00:00 2001 From: Syed Ahmer Shah Date: Mon, 23 Nov 2026 19:22:53 +0500 Subject: [PATCH] Drop whitespace-only tags in compute_tags --- CHANGELOG.md | 4 ++++ src/zimscraperlib/inputs.py | 5 ++--- tests/inputs/test_inputs.py | 6 ++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77dcde7..1500172 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- `compute_tags` no longer returns an empty tag for whitespace-only values (#412) + ## [5.6.0] - 2026-11-20 ### Added diff --git a/src/zimscraperlib/inputs.py b/src/zimscraperlib/inputs.py index 49f36ac..d033fe3 100644 --- a/src/zimscraperlib/inputs.py +++ b/src/zimscraperlib/inputs.py @@ -129,9 +129,8 @@ def compute_tags( Returns a set of tags, ready to be passed to the creator """ - return { - tag.strip() for tag in list(default_tags) + (user_tags or "").split(";") if tag - } + tags = (tag.strip() for tag in list(default_tags) + (user_tags or "").split(";")) + return {tag for tag in tags if tag} def unique_values[T](items: list[T]) -> list[T]: diff --git a/tests/inputs/test_inputs.py b/tests/inputs/test_inputs.py index f768481..4a5aa51 100644 --- a/tests/inputs/test_inputs.py +++ b/tests/inputs/test_inputs.py @@ -319,6 +319,12 @@ def test_description( {"tag1", "tag2", "ta:g,4"}, id="case2", ), + pytest.param( + {"tag1", " "}, + "tag2; ;tag3; ", + {"tag1", "tag2", "tag3"}, + id="whitespace_only", + ), ], ) def test_compute_tags(