From 384eb859b83df38f7eee0dfd20a4098109a782c1 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 14 May 2023 20:29:24 +0000 Subject: [PATCH] Type hints and docstrings. --- matcher/api.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/matcher/api.py b/matcher/api.py index b837735..e0fa792 100644 --- a/matcher/api.py +++ b/matcher/api.py @@ -304,7 +304,8 @@ WHERE tags ? 'wikidata' return tagged -def get_items(item_ids): +def get_items(item_ids: list[int]) -> list[model.Item]: + """Get a Wikidata items with the given item IDs.""" items = [] for item_id in item_ids: item = model.Item.query.get(item_id) @@ -317,8 +318,8 @@ def get_items(item_ids): return items -def get_item_tags(item): - isa_list = [v["numeric-id"] for v in item.get_isa()] +def get_item_tags(item: model.Item) -> dict[str, list[str]]: + isa_list: list[int] = [v["numeric-id"] for v in item.get_isa()] isa_items = [(isa, []) for isa in get_items(isa_list)] osm_list = defaultdict(list)