From 00b2e113bf4c3f128a09e3f816d5382dda9aed32 Mon Sep 17 00:00:00 2001 From: Miel Vander Sande Date: Thu, 7 May 2026 10:09:40 +0200 Subject: [PATCH 1/3] Explicitely test for None when assigning False to context mapping --- lib/pyld/jsonld.py | 6 ++++-- tests/runtests.py | 5 +---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py index acca64d6..f715fe0e 100644 --- a/lib/pyld/jsonld.py +++ b/lib/pyld/jsonld.py @@ -5709,8 +5709,10 @@ def _create_term_definition( # scoped contexts if '@context' in value: - # record as falss, if None - mapping['@context'] = value['@context'] if value['@context'] else False + # record as false, if None + mapping['@context'] = ( + False if value['@context'] is None else value['@context'] + ) if '@language' in value and '@type' not in value: language = value['@language'] diff --git a/tests/runtests.py b/tests/runtests.py index 3e5b71fa..9a1bdee1 100644 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -904,10 +904,7 @@ def write(self, filename): # skip tests where behavior changed for a 1.1 processor # see JSON-LD 1.0 Errata 'specVersion': ['json-ld-1.0'], - 'idRegex': [ - # uncategorized - '.*compact-manifest#tc028$', - ], + 'idRegex': [], }, 'fn': 'compact', 'params': [ From dfa8d4b4daf1c72b347f001b7b774d2195996455 Mon Sep 17 00:00:00 2001 From: Miel Vander Sande Date: Thu, 7 May 2026 10:11:51 +0200 Subject: [PATCH 2/3] Also pass toRdf-manifest#tc036 and add regression test --- tests/runtests.py | 1 - tests/test_jsonld.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/runtests.py b/tests/runtests.py index 9a1bdee1..a8a72abf 100644 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -1030,7 +1030,6 @@ def write(self, filename): '.*toRdf-manifest#ter56$', '.*toRdf-manifest#tli12$', '.*toRdf-manifest#tli14$', - '.*toRdf-manifest#tc036$', '.*toRdf-manifest#tc037$', ] }, diff --git a/tests/test_jsonld.py b/tests/test_jsonld.py index d1fd80ee..6f9699d6 100644 --- a/tests/test_jsonld.py +++ b/tests/test_jsonld.py @@ -892,6 +892,37 @@ def test_node_reference_compacts_to_string_value_of_type_map(self): "location": {"@none": "http://kg.artsdata.ca/resource/K11-200"}, } + def test_empty_property_scoped_context_preserves_outer_terms(self): + """ + An empty property-scoped context should not reset the active context + during compaction. + """ + expanded = [ + { + "http://example.com/title": [{"@value": "top"}], + "http://example.com/thing": [ + { + "http://example.com/title": [{"@value": "sub"}], + } + ], + } + ] + context = { + "@context": { + "ex": "http://example.com/", + "thing": {"@id": "ex:thing", "@context": {}}, + "title": "ex:title", + } + } + + compacted = jsonld.compact(expanded, context, {"skipExpansion": True}) + + assert compacted == { + "@context": context["@context"], + "title": "top", + "thing": {"title": "sub"}, + } + # Issue 91 def test_empty_context(self): """ From 7045f5e2ecb5c77a83c6b89199a5056d31137a8f Mon Sep 17 00:00:00 2001 From: Miel Vander Sande Date: Mon, 11 May 2026 11:40:24 +0200 Subject: [PATCH 3/3] Append changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f6f035c..04527788 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixed - When compacting, expands the index mapping first, then compacts that expanded IRI, matching the JSON-LD API compaction correction for compact-IRI index mappings. Fixes testcases [compact#t0112](https://w3c.github.io/json-ld-api/tests/compact-manifest.html#t0112) and [compact#t0113](https://w3c.github.io/json-ld-api/tests/compact-manifest.html#t0113). - Fixes `AttributeError` when compacting with `@none`: the `@type` map compaction path now only calls `.pop()` and inspects keys when `compacted_item` is actually an object. Fixes [compact#tm023](https://w3c.github.io/json-ld-api/tests/compact-manifest.html#tm023) +- An empty property-scoped context no longer resets the active context in `_create_term_definition`. Now only explicit null becomes False; empty contexts are preserved. Fixes [compact#tc028](https://w3c.github.io/json-ld-api/tests/compact-manifest.html#tc028) and [toRdf#tc036](https://w3c.github.io/json-ld-api/tests/toRdf-manifest.html#tc036). ### Added - `pyld.DocumentLoader` abstract base class for class-based document loaders,