From f55e7ec4cb7cffbe62a7a81612884e590a82dfa6 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Fri, 20 Sep 2024 16:53:39 +0300 Subject: Remove one-line if/else statement. * gn3/db/rdf/wiki.py (__sanitize_result): When fetching pubmed_ids and categories, default to [] if the key misses, and remove the subsequent one-line if/else statement. Signed-off-by: Munyoki Kilyungi --- gn3/db/rdf/wiki.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gn3/db/rdf/wiki.py b/gn3/db/rdf/wiki.py index 4464eed..6624886 100644 --- a/gn3/db/rdf/wiki.py +++ b/gn3/db/rdf/wiki.py @@ -40,13 +40,13 @@ def __sanitize_result(result: dict) -> dict: """Make sure `categories` and `pubmed_ids` are always arrays""" if not result: return {} - categories = result.get("categories") + categories = result.get("categories", []) if isinstance(categories, str): - result["categories"] = [categories] if categories else [] + result["categories"] = [categories] result["categories"] = sorted(result["categories"]) - pmids = result.get("pubmed_ids") + pmids = result.get("pubmed_ids", []) if isinstance(pmids, str): - result["pubmed_ids"] = [pmids] if pmids else [] + result["pubmed_ids"] = [pmids] if isinstance(pmids, int): result["pubmed_ids"] = [pmids] result["pubmed_ids"] = [ -- cgit v1.2.3