Simplify _relation_attributes() (#2215)

Use try/except as the key should be always there, and that's the fastest in such case.
Except is there to prevent any issue if the API does something weird.
This commit is contained in:
Laurent Monin
2023-05-30 10:10:02 +02:00
committed by GitHub
parent e01a43dc4b
commit 16507ff4a3

View File

@@ -139,9 +139,10 @@ def _parse_attributes(attrs, reltype, attr_credits):
def _relation_attributes(relation):
if 'attributes' in relation:
return tuple(a for a in relation['attributes'])
return tuple()
try:
return tuple(relation['attributes'])
except KeyError:
return tuple()
def _relations_to_metadata_target_type_artist(relation, m, context):