Skip to content

Commit

Permalink
Fix typo that breaks get_child_databases retriever (#1411)
Browse files Browse the repository at this point in the history
* Fix typo that breaks child database retriever

* Tidy up messy typed code
  • Loading branch information
ml-evs authored Dec 3, 2022
1 parent 105b501 commit f28bee2
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions optimade/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,20 @@ def get_child_database_links(

try:
links_resp = LinksResponse(**links.json())
except (ValidationError, json.JSONDecodeError) as exc:
raise RuntimeError(
f"Did not understand response from {provider['id']}: {links.content!r}"
) from exc

if isinstance(links_resp.data, LinksResource):
return [
link
for link in links_resp.data
if link.attributes.link_type == LinkType.CHILD
if isinstance(link, LinksResource)
and link.attributes.link_type == LinkType.CHILD
and link.attributes.base_url is not None
and (not obey_aggregate or link.attributes.aggregate == Aggregate.OK)
]

else:
raise RuntimeError("Invalid links responses received: {links.content!r")
except (ValidationError, json.JSONDecodeError) as exc:
raise RuntimeError(
f"Did not understand response from {provider['id']}: {links.content!r}"
) from exc


def get_all_databases() -> Iterable[str]:
Expand Down

0 comments on commit f28bee2

Please sign in to comment.