Skip to content

Commit 878af52

Browse files
committed
check isinstance(options['link'], dict)
An empty dict is not truthy in python, so cannot just check for "if options['link']" Fixes #64
1 parent 99aca07 commit 878af52

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/pyld/jsonld.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ def compact(self, input_, ctx, options):
712712
options.setdefault('activeCtx', False)
713713
options.setdefault('documentLoader', _default_document_loader)
714714
options.setdefault('link', False)
715-
if options['link']:
715+
if isinstance(options['link'], dict):
716716
# force skip expansion when linking, "link" is not part of the
717717
# public API, it should only be called from framing
718718
options['skipExpansion'] = True
@@ -1752,7 +1752,7 @@ def _compact(self, active_ctx, active_property, element, options):
17521752
if _is_value(element) or _is_subject_reference(element):
17531753
rval = self._compact_value(
17541754
active_ctx, active_property, element)
1755-
if options['link'] and _is_subject_reference(element):
1755+
if isinstance(options['link'], dict) and _is_subject_reference(element):
17561756
# store linked element
17571757
options['link'].setdefault(element['@id'], []).append(
17581758
{'expanded': element, 'compacted': rval})
@@ -1763,7 +1763,7 @@ def _compact(self, active_ctx, active_property, element, options):
17631763

17641764
rval = {}
17651765

1766-
if options['link'] and '@id' in element:
1766+
if isinstance(options['link'], dict) and '@id' in element:
17671767
# store linked element
17681768
options['link'].setdefault(element['@id'], []).append(
17691769
{'expanded': element, 'compacted': rval})

0 commit comments

Comments
 (0)