Skip to content

Commit

Permalink
Let jsonld handle value nodes/Literal for context search (#2750)
Browse files Browse the repository at this point in the history
* jsonld ignores value nodes in search of a context

* black format

---------

Co-authored-by: WhiteGobo <[email protected]>
  • Loading branch information
WhiteGobo and WhiteGobo authored Apr 18, 2024
1 parent 6b203a6 commit b90987d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions rdflib/plugins/shared/jsonld/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,15 @@ def get_context_for_type(self, node: Any) -> Optional[Context]:
if not isinstance(rtype, list):
rtype = [rtype] if rtype else []

typeterm = None
for rt in rtype:
typeterm = self.terms.get(rt)
if typeterm:
try:
typeterm = self.terms.get(rt)
except TypeError:
# extra lenience, triggers if type is set to a literal
pass
if typeterm is not None:
break
else:
typeterm = None

if typeterm and typeterm.context:
subcontext = self.subcontext(typeterm.context, propagate=False)
Expand Down

0 comments on commit b90987d

Please sign in to comment.