From 35358c2bc09959cefce30865557298bbeaab0fa4 Mon Sep 17 00:00:00 2001 From: John Nduli Date: Thu, 13 Jun 2024 18:50:27 +0300 Subject: fix: typehints in index-genenetwork script --- scripts/index-genenetwork | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/index-genenetwork b/scripts/index-genenetwork index e0f6d81..ebf04e7 100755 --- a/scripts/index-genenetwork +++ b/scripts/index-genenetwork @@ -190,8 +190,11 @@ _:node rdf:type gnc:GNWikiEntry ; } GROUP BY ?speciesName ?symbolName """ sparql.setQuery(query) - results = sparql.queryAndConvert()["results"]["bindings"] - for entry in results: + results = sparql.queryAndConvert() + if not isinstance(results, dict): + raise TypeError(f"Expected results to be a dict but found {type(results)}") + bindings = results["results"]["bindings"] + for entry in bindings : x = (entry["speciesName"]["value"], entry["symbolName"]["value"],) cache[x] = entry["comment"]["value"] return cache @@ -221,8 +224,11 @@ _:node rdf:type gnc:GNWikiEntry ; } GROUP BY ?type """ sparql.setQuery(query) - results = sparql.queryAndConvert()["results"]["bindings"] - return results[0]["hash"]["value"] + results = sparql.queryAndConvert() + if not isinstance(results, dict): + raise TypeError(f"Expected results to be a dict but found {type(results)}") + bindings = results["results"]["bindings"] + return bindings[0]["hash"]["value"] # pylint: disable=invalid-name @@ -456,7 +462,7 @@ def is_data_modified(xapian_directory: str, dir_ = pathlib.Path(xapian_directory) with locked_xapian_writable_database(dir_) as db, database_connection(sql_uri) as conn: checksums = " ".join([ - result["Checksum"].bind(str) + str(result["Checksum"].value) for result in query_sql( conn, f"CHECKSUM TABLE {', '.join(db.get_metadata('tables').decode().split())}") -- cgit v1.2.3