From 72063f2e2b72070cd3697eefc530e87bd70a483d Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Wed, 19 Jun 2024 14:54:24 +0100 Subject: [PATCH] Bug fix expand_street_name --- web_view.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/web_view.py b/web_view.py index 9003fde..16049b3 100755 --- a/web_view.py +++ b/web_view.py @@ -555,7 +555,8 @@ def api_get_item_tags(item_id): ) -def expand_street_name(from_names): +def expand_street_name(from_names: typing.Collection[str]) -> set[str]: + """Expand street name.""" ret = set(from_names) for name in from_names: if any(name.startswith(st) for st in ("St ", "St. ")): @@ -563,12 +564,10 @@ def expand_street_name(from_names): ret.add("Saint" + name[first_space:]) if ", " in name: - for n in set(ret): - comma = n.find(", ") - ret.add(name[:comma]) + comma = name.find(", ") + ret.add(name[:comma]) elif "/" in name: - for n in set(ret): - ret.extend(part.strip() for part in n.split("/")) + ret.update(part.strip() for part in name.split("/")) ret.update({"The " + name for name in ret if not name.startswith("The ")}) return ret