diff options
author | Munyoki Kilyungi | 2024-09-10 10:49:50 +0300 |
---|---|---|
committer | BonfaceKilz | 2024-09-11 10:30:57 +0300 |
commit | a7d9165a7ca1e6b9e7fdeb6fba61ebf335c6a0d3 (patch) | |
tree | d5832c702c41244e7de94e78b5dfcda256c0447f /gn3/db | |
parent | 0b07792d38e83ee36a942b80fefb7de81778aa9f (diff) | |
download | genenetwork3-a7d9165a7ca1e6b9e7fdeb6fba61ebf335c6a0d3.tar.gz |
Handle case when result is empty when sanitizing json-ld result.
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn3/db')
-rw-r--r-- | gn3/db/rdf/wiki.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/gn3/db/rdf/wiki.py b/gn3/db/rdf/wiki.py index 03945ec..7d0b3f3 100644 --- a/gn3/db/rdf/wiki.py +++ b/gn3/db/rdf/wiki.py @@ -31,8 +31,10 @@ WIKI_CONTEXT = BASE_CONTEXT | { } -def __sanitize_result(result: dict): +def __sanitize_result(result: dict) -> dict: """Make sure `categories` and `pubmed_ids` are always arrays""" + if not result: + return {} categories = result.get("categories") if isinstance(categories, str): result["categories"] = [categories] if categories else [] |