diff --git a/CHANGELOG.md b/CHANGELOG.md index 71166a9b0..b2c8acc1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - Preserved RDF literal lexical forms when converting through RDFLib, including canonical double output, large numeric values, and compound literal handling. - Fixed the active context clone dropping the default base direction: `@direction` now survives context layers like `@language`. Fixes [issue #337](https://github.com/digitalbazaar/pyld/issues/337). +- Fixed `@embed: @never` being ignored for reverse-framed properties because of a misspelled `embedded` framing state key. Fixes [issue #378](https://github.com/digitalbazaar/pyld/issues/378). - Fixed `KeyError` when a context sets `@direction: null` and no default base direction is in effect. - Fixed `iri_resolver.unresolve()` query/fragment reconstruction while cleaning up the resolver docstring. - Invalid IRI base values within lists are now skipped when serializing to RDF. Fixes [toRdf#tli12](https://w3c.github.io/json-ld-api/tests/toRdf-manifest#tli12) and [toRdf#tli14](https://w3c.github.io/json-ld-api/tests/toRdf-manifest#tli14). @@ -33,6 +34,12 @@ - Use a helper for generalized N-Quads normalization in the test runner, since rdflib cannot parse blank-node predicates. Fixes [toRdf#te075](https://w3c.github.io/json-ld-api/tests/toRdf-manifest#te075). - `jsonld.expand()`, `jsonld.to_rdf()` and the other operations no longer fail with an `OverflowError` for an integer too large for a double. `jsonld.to_rdf()` writes it as `INF` or `-INF`, the infinite `xsd:double` values, or, in `json-ld-1.0` mode and not typed as `xsd:double`, as an exact `xsd:integer`. Inside `@json` literals, `jsonld.to_rdf()` and `jsonld.normalize()` still raise `OverflowError` for such numbers, as RFC 8785 only allows numbers that fit in a double. - `jsonld.to_rdf()` writes the `xsd:double` NaN as `NaN`, its XSD canonical form, instead of `NAN`, so `jsonld.normalize()` output changes for documents with such a value. +- Fixed `iri_resolver.resolve()` to + - fix references without a scheme or host against a base IRI with a host and no path (`/x` against `http://example.org` gave `http://example.org//x`) or with a query, and keeps the dot of a first segment such as `.gh`. + - treat a reference with a `/`, `?` or `#` before its first `:`, such as `/a:b`, `x/y:z` or `a?b:c`, as a relative IRI and resolves it against the base IRI, as RFC 3986 does. It was returned unresolved, so `jsonld.to_rdf()` dropped it. +- `iri_resolver.remove_dot_segments()`, and with it `iri_resolver.resolve()`, no longer drops the `/` that a final `.` or `..` segment leaves before a query or fragment (`/a/.?x` gave `/a?x`). +- A term whose name contains a `:` or a `/`, such as `/a/`, is no longer a prefix, as [Create Term Definition](https://www.w3.org/TR/json-ld11-api/#create-term-definition) step 14.2.5 requires. `jsonld.expand()` read `/a/:b` as a compact IRI with that term instead of as a relative IRI, and `jsonld.compact()` wrote such compact IRIs. A context with a term such as `/a/:b` can now fail, or newly pass, the check that the term expands to its own IRI. +- `jsonld.compact()` builds a compact IRI only from a term with the prefix flag, as [IRI Compaction](https://www.w3.org/TR/json-ld11-api/#iri-compaction) step 7.1 requires, also when the compact IRI is itself a term for the IRI. With `{"ex": "http://example.org/ns", "ex:foo": {"@type": "@id"}}`, `http://example.org/nsfoo` was compacted to `ex:foo`, which doesn't expand back to it. ### Changed - **BREAKING**: Developer install, command execution, documentation, and release artifact diff --git a/lib/pyld/iri_resolver.py b/lib/pyld/iri_resolver.py index 2090a68fa..4389c8cbd 100644 --- a/lib/pyld/iri_resolver.py +++ b/lib/pyld/iri_resolver.py @@ -46,8 +46,9 @@ def remove_dot_segments(path: str) -> str: if segment_buffers: segment_buffers.pop() - # Add trailing slash segment if ends with '/..' - if i + 3 >= length: + # Add trailing slash segment if the path ends with '/..', + # also before a query or fragment + if next_ch != '/': segment_buffers.append([]) i += 3 @@ -60,8 +61,9 @@ def remove_dot_segments(path: str) -> str: i += 1 continue - # Add trailing slash if ends with '/.' - if i + 2 >= length: + # Add trailing slash if the path ends with '/.', + # also before a query or fragment + if next_ch != '/': segment_buffers.append([]) # Stay in current directory — skip @@ -97,7 +99,8 @@ def remove_dot_segments_of_path(iri: str, colon_position: int) -> str: Remove dot segments from the path portion of an IRI (RFC 3986 §5.2.4). :param iri: an IRI (or part of IRI). - :param colonPosition: the position of the first ':' in the IRI. + :param colon_position: the position of the ':' that ends the scheme of the + IRI, or -1 if it has no scheme. :return: the IRI where dot segments were removed. """ @@ -114,9 +117,12 @@ def remove_dot_segments_of_path(iri: str, colon_position: int) -> str: else: search_offset = 2 if len(iri) > 1 and iri[0] == '/' and iri[1] == '/' else 0 - # Find the start of the path + # Find the start of the path: the first '/', unless a query or fragment + # starts before it path_separator = iri.find('/', search_offset) - if path_separator < 0: + if path_separator < 0 or any( + ch in iri[search_offset:path_separator] for ch in '?#' + ): return iri base = iri[:path_separator] @@ -150,17 +156,20 @@ def resolve(relative_iri: str, base_iri: str = None) -> str: ) return base_iri - # If the value starts with a query character, concat directly (strip existing query) - if relative_iri.startswith("?"): - base_query_pos = base_iri.find("?") - if base_query_pos > 0: - base_iri = base_iri[:base_query_pos] - return base_iri + relative_iri - # If the value starts with a fragment character, concat directly if relative_iri.startswith("#"): return base_iri + relative_iri + # The query of the base IRI only applies to an empty value or a fragment + # (RFC 3986, section 5.2.2) + base_query_pos = base_iri.find("?") + if base_query_pos > 0: + base_iri = base_iri[:base_query_pos] + + # If the value starts with a query character, concat directly + if relative_iri.startswith("?"): + return base_iri + relative_iri + # Ignore baseIRI if it is empty if not base_iri: relative_colon_pos = relative_iri.find(":") @@ -170,10 +179,15 @@ def resolve(relative_iri: str, base_iri: str = None) -> str: ) return remove_dot_segments_of_path(relative_iri, relative_colon_pos) - # Ignore baseIRI if the value is absolute + # Ignore baseIRI if the value is absolute. + # Per RFC 3986, a URI scheme cannot contain a '/', '?' or '#', so if one of + # them appears before the first ':', the IRI is relative (not absolute). value_colon_pos = relative_iri.find(":") - if value_colon_pos >= 0: + if value_colon_pos >= 0 and not any( + ch in relative_iri[:value_colon_pos] for ch in "/?#" + ): return remove_dot_segments_of_path(relative_iri, value_colon_pos) + # From here on, the value has no scheme: a ':' in it does not end a scheme. # baseIRI must be absolute base_colon_pos = base_iri.find(":") @@ -186,28 +200,23 @@ def resolve(relative_iri: str, base_iri: str = None) -> str: # Inherit base scheme if relative starts with '//' if relative_iri.startswith("//"): - return base_scheme + remove_dot_segments_of_path(relative_iri, value_colon_pos) + return base_scheme + remove_dot_segments_of_path(relative_iri, -1) # Determine where the path of base starts if base_iri.find("//", base_colon_pos) == base_colon_pos + 1: base_slash_after_colon_pos = base_iri.find("/", base_colon_pos + 3) if base_slash_after_colon_pos < 0: if len(base_iri) > base_colon_pos + 3: - return ( - base_iri - + "/" - + remove_dot_segments_of_path(relative_iri, value_colon_pos) - ) + # The base has an authority and an empty path, so its path is + # taken as '/' (RFC 3986, section 5.2.3) + base_iri += "/" + base_slash_after_colon_pos = len(base_iri) - 1 else: - return base_scheme + remove_dot_segments_of_path( - relative_iri, value_colon_pos - ) + return base_scheme + remove_dot_segments_of_path(relative_iri, -1) else: base_slash_after_colon_pos = base_iri.find("/", base_colon_pos + 1) if base_slash_after_colon_pos < 0: - return base_scheme + remove_dot_segments_of_path( - relative_iri, value_colon_pos - ) + return base_scheme + remove_dot_segments_of_path(relative_iri, -1) # If relative starts with '/', append after base authority if relative_iri.startswith("/"): @@ -219,13 +228,6 @@ def resolve(relative_iri: str, base_iri: str = None) -> str: # Ignore everything after last '/' in base path if last_slash >= 0 and last_slash < len(base_path) - 1: base_path = base_path[: last_slash + 1] - if ( - relative_iri.startswith(".") - and not relative_iri.startswith("..") - and not relative_iri.startswith("./") - and len(relative_iri) > 2 - ): - relative_iri = relative_iri[1:] relative_iri = base_path + relative_iri relative_iri = remove_dot_segments(relative_iri) diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py index cdc9159f8..338229bd3 100644 --- a/lib/pyld/jsonld.py +++ b/lib/pyld/jsonld.py @@ -4660,7 +4660,7 @@ def _match_frame(self, state, subjects, frame, parent, property): {'propertyIsArray': True}, ) self._match_frame( - {**state, 'embeded': True}, + {**state, 'embedded': True}, [subject], subframe, output['@reverse'][reverse_prop], @@ -5398,14 +5398,13 @@ def _compact_iri( ): continue - # a CURIE is usable if: + # a CURIE is usable if the term is a prefix and: # 1. it has no mapping, OR # 2. value is None, which means we're not compacting an @value, AND # the mapping matches the IRI curie = term + ':' + iri[len(definition['@id']) :] - is_usable_curie = ( - active_ctx['mappings'][term]['_prefix'] - and curie not in active_ctx['mappings'] + is_usable_curie = active_ctx['mappings'][term]['_prefix'] and ( + curie not in active_ctx['mappings'] or ( value is None and active_ctx['mappings'].get(curie, {}).get('@id') == iri @@ -5802,9 +5801,12 @@ def _create_term_definition( ) mapping['@id'] = id_ + # only a simple term without ':' or '/' may be a prefix + # (Create Term Definition, step 14.2.5) mapping['_prefix'] = ( _simple_term - and not mapping['_term_has_colon'] + and ':' not in term + and '/' not in term and ( id_.startswith('_:') or bool(re.match(r'.*[:/\?#\[\]@]$', id_)) diff --git a/specifications/json-ld-api b/specifications/json-ld-api index 92f07705a..a1732db52 160000 --- a/specifications/json-ld-api +++ b/specifications/json-ld-api @@ -1 +1 @@ -Subproject commit 92f07705a0c0ac27aa9bc6fe1322dcc9fad0114d +Subproject commit a1732db52b10222a7c39e79dc93b12f3b873ebfd diff --git a/specifications/rdf-canon b/specifications/rdf-canon index 15619df2f..5ffaaa13c 160000 --- a/specifications/rdf-canon +++ b/specifications/rdf-canon @@ -1 +1 @@ -Subproject commit 15619df2fda7a4ca88308733789b6774517f9638 +Subproject commit 5ffaaa13c0e19a2a2f9e60d0ecd9efaf3edab633 diff --git a/tests/iri_resolver/test_remove_dot_segments.py b/tests/iri_resolver/test_remove_dot_segments.py index 95a33681f..7300b6451 100644 --- a/tests/iri_resolver/test_remove_dot_segments.py +++ b/tests/iri_resolver/test_remove_dot_segments.py @@ -100,7 +100,7 @@ def test_not_modify_parent_paths_in_queries(): def test_mixed_current_and_parent_with_fragment(): - assert remove_dot_segments('/abc/def/./ghi/../..#abc') == '/abc#abc' + assert remove_dot_segments('/abc/def/./ghi/../..#abc') == '/abc/#abc' def test_fragment_without_another_path(): @@ -151,6 +151,22 @@ def test_end_with_slash_if_trailing_slash_dot(): assert remove_dot_segments('/a/bb/ccc/./g/.') == '/a/bb/ccc/g/' +def test_end_with_slash_if_slash_dot_before_query(): + assert remove_dot_segments('/abc/def/.?a=b') == '/abc/def/?a=b' + + +def test_end_with_slash_if_slash_dot_before_fragment(): + assert remove_dot_segments('/abc/def/.#abc') == '/abc/def/#abc' + + +def test_end_with_slash_if_slash_double_dot_before_query(): + assert remove_dot_segments('/abc/def/..?a=b') == '/abc/?a=b' + + +def test_end_with_slash_if_slash_double_dot_before_fragment(): + assert remove_dot_segments('/abc/def/..#abc') == '/abc/#abc' + + def test_triple_dots_as_normal_segment(): assert remove_dot_segments('/invalid/...') == '/invalid/...' diff --git a/tests/iri_resolver/test_resolve.py b/tests/iri_resolver/test_resolve.py index 92082e33b..af6434fc3 100644 --- a/tests/iri_resolver/test_resolve.py +++ b/tests/iri_resolver/test_resolve.py @@ -63,6 +63,13 @@ def test_non_absolute_base_error(): resolve('abc', 'def') +def test_base_without_scheme_colon_only_in_query_error(): + with pytest.raises( + ValueError, match=r"Found invalid baseIRI 'def' for value 'abc'" + ): + resolve('abc', 'def?x:y') + + def test_non_absolute_base_empty_value_error(): with pytest.raises(ValueError, match=r"Found invalid baseIRI 'def' for value ''"): resolve('', 'def') @@ -80,6 +87,101 @@ def test_base_without_path_dot_segments(): assert resolve('abc/./', 'http://base.org') == 'http://base.org/abc/' +def test_base_without_path_root_path(): + assert resolve('/', 'http://base.org') == 'http://base.org/' + + +def test_base_without_path_absolute_path(): + assert resolve('/abc', 'http://base.org') == 'http://base.org/abc' + + +def test_base_without_path_absolute_path_with_dot_segments(): + assert resolve('/abc/../def', 'http://base.org') == 'http://base.org/def' + + +def test_base_without_path_parent_segment(): + assert resolve('../abc', 'http://base.org') == 'http://base.org/abc' + + +def test_base_without_path_relative_with_query(): + assert resolve('abc?x=1', 'http://base.org') == 'http://base.org/abc?x=1' + + +def test_base_without_path_dot_segments_in_query(): + assert resolve('abc?x=/../y', 'http://base.org') == 'http://base.org/abc?x=/../y' + + +def test_base_without_path_double_dot(): + assert resolve('..', 'http://base.org') == 'http://base.org/' + + +def test_base_without_path_dot(): + assert resolve('.', 'http://base.org') == 'http://base.org/' + + +def test_base_without_path_dot_slash(): + assert resolve('./', 'http://base.org') == 'http://base.org/' + + +def test_base_without_path_dot_slash_segment(): + assert resolve('./abc', 'http://base.org') == 'http://base.org/abc' + + +def test_base_without_path_dot_segment_before_query(): + assert resolve('abc/.?x', 'http://base.org') == 'http://base.org/abc/?x' + + +def test_base_without_path_double_dot_segment_before_fragment(): + assert resolve('abc/def/..#x', 'http://base.org') == 'http://base.org/abc/#x' + + +def test_base_without_path_ignores_base_query(): + assert resolve('abc', 'http://base.org?q') == 'http://base.org/abc' + + +def test_base_without_path_relative_with_dot_segments(): + assert resolve('abc/../def', 'http://base.org') == 'http://base.org/def' + + +def test_base_without_path_with_slash_in_query(): + assert resolve('/', 'http://base.org?a/b') == 'http://base.org/' + + +def test_base_with_slash_in_query(): + assert resolve('jjj', 'http://abc/def?ghi/jkl') == 'http://abc/jjj' + + +def test_base_dot_segment_before_query(): + assert resolve('abc/.?x', 'http://base.org/') == 'http://base.org/abc/?x' + + +def test_base_with_query_dot_before_query(): + assert resolve('.?y', 'http://abc/def/?x') == 'http://abc/def/?y' + + +def test_base_with_query_dot_before_fragment(): + assert resolve('.#y', 'http://abc/def/?x') == 'http://abc/def/#y' + + +def test_base_segment_starting_with_dot(): + assert resolve('.gh', 'http://example.org/a') == 'http://example.org/.gh' + + +def test_base_first_segment_starting_with_dot(): + assert ( + resolve('.x/a', 'http://ex.org/x/yy/zzz/f.ttl') + == 'http://ex.org/x/yy/zzz/.x/a' + ) + + +def test_absolute_dot_segment_before_query(): + assert resolve('http://abc/def/.?x') == 'http://abc/def/?x' + + +def test_network_path_double_dot_segment_before_fragment(): + assert resolve('//abc/def/ghi/..#x', 'http://base.org/') == 'http://abc/def/#x' + + def test_base_only_scheme_slash_slash(): assert resolve('abc', 'http://') == 'http:abc' @@ -378,3 +480,59 @@ def test_relative_with_triple_dot_segment_and_2x_double_dot_and_base(): def test_questionmark_prefix_relative_with_complex_base_with_dot(): assert resolve('?y', 'http://a/bb/ccc/./d;p?q') == 'http://a/bb/ccc/./d;p?y' + + +def test_relative_with_slash_before_colon_and_base_with_trailing_slash(): + assert resolve('x/y:z', 'http://base.org/path/') == 'http://base.org/path/x/y:z' + + +def test_relative_with_slash_before_colon_and_base_without_trailing_slash(): + assert resolve('x/y:z', 'http://base.org/path') == 'http://base.org/x/y:z' + + +def test_relative_with_multiple_colons_after_slash(): + assert resolve('x/y:z:w', 'http://base.org/path/') == 'http://base.org/path/x/y:z:w' + + +def test_absolute_path_with_colon_and_base(): + assert resolve('/a:b', 'http://base.org/path/') == 'http://base.org/a:b' + + +def test_absolute_path_with_colon_and_dot_segments_and_base_without_path(): + assert resolve('/a:b/../c', 'http://base.org') == 'http://base.org/c' + + +def test_relative_with_question_mark_before_colon(): + assert resolve('a?b:c', 'http://base.org/path/x') == 'http://base.org/path/a?b:c' + + +def test_relative_with_hash_before_colon(): + assert resolve('a#b:c', 'http://base.org/path/x') == 'http://base.org/path/a#b:c' + + +def test_network_path_with_dot_segment_before_colon(): + assert resolve('//h/./a:b', 'http://base.org/path/') == 'http://h/a:b' + + +def test_relative_with_dot_segment_before_colon_and_base_without_slash_slash(): + assert resolve('x/./y:z', 'tag:example') == 'tag:x/y:z' + + +def test_network_path_with_colon_and_dot_segment_before_query(): + assert resolve('//h/a:b/.?q', 'http://x/') == 'http://h/a:b/?q' + + +def test_relative_with_colon_and_dot_segment_before_query_and_base_without_slash_slash(): + assert resolve('z/a:b/.?', 'urn:x') == 'urn:z/a:b/?' + + +def test_relative_with_dot_segments_and_colon_in_query(): + assert resolve('doc?next=/a/../b:c', 'urn:x:y') == 'urn:doc?next=/a/../b:c' + + +def test_relative_with_dot_segments_and_colon_in_fragment(): + assert resolve('doc#/a/../b:c', 'tag:example') == 'tag:doc#/a/../b:c' + + +def test_absolute_iri_with_dot_segments_in_query(): + assert resolve('urn:x?a/../b') == 'urn:x?a/../b' diff --git a/tests/jsonld/test_compact.py b/tests/jsonld/test_compact.py index 16ee9bf66..275ace9a5 100644 --- a/tests/jsonld/test_compact.py +++ b/tests/jsonld/test_compact.py @@ -319,3 +319,54 @@ def test_with_vocab_with_id(): compacted = jsonld.compact(input, ctx) assert compacted == expected + +def test_term_with_slash_is_not_used_as_a_prefix(): + """ + Compaction must not write a compact IRI with a term whose name contains + a '/': a reader resolves '/a/:b' as a relative IRI. + + See: https://www.w3.org/TR/json-ld11-api/#create-term-definition + (step 14.2.5) + """ + ctx = {'@vocab': 'http://example.org', '/a/': 'http://example.org/a/'} + input = { + '@id': 'http://example.org/s', + 'http://example.org/p': {'@id': 'http://example.org/a/b'}, + } + + compacted = jsonld.compact(input, ctx) + + assert compacted['/p'] == {'@id': 'http://example.org/a/b'} + +@pytest.mark.parametrize( + ('ctx', 'iri'), + [ + # '/a/:b' is a term for the IRI, but '/a/' is not a prefix + ( + { + '@vocab': 'http://other.org', + '/a/': 'http://other.org/a/', + '/a/:b': {'@type': '@id'}, + }, + 'http://other.org/a/b', + ), + # 'ex:foo' is a term for the IRI, but 'ex' is not a prefix + ( + {'ex': 'http://example.org/ns', 'ex:foo': {'@type': '@id'}}, + 'http://example.org/nsfoo', + ), + ], +) +def test_compact_iri_from_a_term_that_is_not_a_prefix_is_not_used(ctx, iri): + """ + A compact IRI is only built from a term with the prefix flag, also when + the compact IRI is itself a term for the IRI: otherwise it doesn't + expand back to the IRI. + + See: https://www.w3.org/TR/json-ld11-api/#iri-compaction (step 7.1) + """ + input = {'@id': iri, 'http://example.org/p': {'@id': iri}} + + compacted = jsonld.compact(input, ctx) + + assert jsonld.expand(compacted) == jsonld.expand(input) diff --git a/tests/jsonld/test_expand.py b/tests/jsonld/test_expand.py index 05af4999c..7dae1bc48 100644 --- a/tests/jsonld/test_expand.py +++ b/tests/jsonld/test_expand.py @@ -255,6 +255,51 @@ def test_base_does_not_expand_property_terms(): } ] +def test_term_with_slash_is_not_a_prefix(): + """ + A term whose name contains a '/' is not a prefix, so '/a/:b' is no + compact IRI: as an @id it is resolved against @base, and as a property + it is relative to @vocab. + + See: https://www.w3.org/TR/json-ld11-api/#create-term-definition + (step 14.2.5) + """ + doc = { + '@context': { + '@base': 'http://example.org/ns/doc', + '@vocab': 'http://other.org', + '/a/': 'http://other.org/a/', + }, + '@id': '/a/:b', + '/a/:b': {'@id': '/a/:b'}, + } + assert jsonld.expand(doc) == [ + { + '@id': 'http://example.org/a/:b', + 'http://other.org/a/:b': [{'@id': 'http://example.org/a/:b'}], + } + ] + +def test_term_name_with_slash_takes_iri_of_its_prefix_term(): + """ + A term such as '/a/:b' without an @id takes the IRI of the term before + its first ':', whether or not that term may be a prefix. + + See: https://www.w3.org/TR/json-ld11-api/#create-term-definition + (step 15) + """ + doc = { + '@context': { + '@vocab': 'http://other.org', + '/a/': 'http://other.org/a/', + '/a/:b': {'@type': '@id'}, + }, + '/a/:b': 'http://example.org/o', + } + assert jsonld.expand(doc) == [ + {'http://other.org/a/b': [{'@id': 'http://example.org/o'}]} + ] + # Issue 143 def test_expand_with_base_from_context(): """Expand with set or not should rely upon @base inside its @context.""" diff --git a/tests/jsonld/test_frame.py b/tests/jsonld/test_frame.py index 7258591b0..443859d9d 100644 --- a/tests/jsonld/test_frame.py +++ b/tests/jsonld/test_frame.py @@ -73,6 +73,41 @@ def test_frame_uses_identifier_issuer_option(): ] } +def test_frame_reverse_embed_never_is_respected(): + # Issue 378: a misspelled state key ignored @embed: @never in @reverse frames + ctx = { + "schema": "http://schema.org/", + "name": "schema:name", + "works_for": {"@id": "schema:worksFor", "@type": "@id"}, + "employees": {"@reverse": "schema:worksFor"}, + } + doc = { + "@context": ctx, + "@graph": [ + {"@id": "ex:org1", "@type": "schema:Organization", "name": "Acme"}, + { + "@id": "ex:p1", + "@type": "schema:Person", + "name": "Ada", + "works_for": "ex:org1", + }, + ], + } + nquads = jsonld.to_rdf(doc, {"format": "application/n-quads"}) + back = jsonld.from_rdf(nquads, {"format": "application/n-quads"}) + + result = jsonld.frame( + back, + { + "@context": ctx, + "@embed": "@once", + "@type": "schema:Organization", + "@reverse": {"schema:worksFor": {"@embed": "@never"}}, + }, + ) + + assert result["employees"] == {"@id": "ex:p1"} + # PR: https://github.com/digitalbazaar/pyld/pull/31 FRAME_0001_IN = { diff --git a/uv.lock b/uv.lock index 70f42d045..203dca1d0 100644 --- a/uv.lock +++ b/uv.lock @@ -281,11 +281,11 @@ wheels = [ [[package]] name = "cachetools" -version = "7.2.8" +version = "7.3.2" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/93/6f/faa5e0606769105e70e0478031a8f9a6b729e329f42ce2462585c6d9aa52/cachetools-7.2.8.tar.gz", hash = "sha256:3f9b146b2160975da273e7c23ec882f3996b65df608150d52083c07de0682075", size = 47821, upload-time = "2026-10-31T21:37:51.986Z" } +sdist = { url = "https://files.pythonhosted.org/packages/0a/d6/3b2743ae0662528e36b1002074909e4e73dc7407f1fc7da0d6a1b7401e72/cachetools-7.3.2.tar.gz", hash = "sha256:43e5db663b58c4337a9959069d93f54dd2e065fdd0438a504cd1100fbeb48beb", size = 50520, upload-time = "2026-11-14T21:19:07.523Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/0c/35/2fb720060bb278759da35f2076fab1af4e9d66e3add080e6b40d6e25ba48/cachetools-7.2.8-py3-none-any.whl", hash = "sha256:09b04a85741d0019b3fb7d02b7ee9933a422fa6923af92a0fd63b893b695830c", size = 19646, upload-time = "2026-10-31T21:37:50.278Z" }, + { url = "https://files.pythonhosted.org/packages/ed/8f/9d90e713bdaf06316184c7214a23177e0fe7b9a287932a5dcce643f6fd58/cachetools-7.3.2-py3-none-any.whl", hash = "sha256:afb4b563cb37e7a121a6ea45a0deec42916c64eed58875cc15d8cf9eaca89fb2", size = 19956, upload-time = "2026-11-14T21:19:05.777Z" }, ] [[package]] @@ -2160,27 +2160,27 @@ wheels = [ [[package]] name = "ruff" -version = "0.17.3" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/59/73/81f140c4edd9cc323de5478e6bbd3bbcfae9a82692df1a258de8cec6a6d2/ruff-0.17.3.tar.gz", hash = "sha256:a57049c8addb3662073859bb55a7ad35aa54f8a7c9ed268911d1333c5aadaaa9", size = 5339444, upload-time = "2026-10-27T00:34:05.914Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/9e/8c/083365310c4e79c842f25bf5a842facbd9b0c0ec336f96dffa5074fe723d/ruff-0.17.3-py3-none-linux_armv6l.whl", hash = "sha256:ab86b84cd9d05e56d329742c0cabdcbe2d1d56c98f4a04aab9b5b66196febfb4", size = 10216522, upload-time = "2026-10-27T00:33:29.822Z" }, - { url = "https://files.pythonhosted.org/packages/72/26/4b2edf31cfebe9605d8f6ed8f1d6f376d3a53d4c9a123e62661c64c440f0/ruff-0.17.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:e407b4a6852853a9a2cdce96963e94ad9775578bb44e7561a0f2829f3cc04b11", size = 10217786, upload-time = "2026-10-27T00:33:33.949Z" }, - { url = "https://files.pythonhosted.org/packages/a2/7e/537aba4b7f54397a374d2f6a6fc93e9c8015e18553f31a4a7b7dbced48b5/ruff-0.17.3-py3-none-macosx_11_0_arm64.whl", hash = "sha256:b75cc113b3aca388933d8296b667b1ac401a80317ea3074c9b0a66541199da29", size = 9440362, upload-time = "2026-10-27T00:33:35.784Z" }, - { url = "https://files.pythonhosted.org/packages/3d/66/283e39734f66c8a5ebaa93c22eb7b7515779a0b1d5a5c0ad20e05c0edb41/ruff-0.17.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ab5fa7ed5ce18554ea69d850ad162cbaa0c85fc47c08d83a569f806681c9a6ad", size = 10094281, upload-time = "2026-10-27T00:33:38.216Z" }, - { url = "https://files.pythonhosted.org/packages/21/4c/1ffc768497bd025a32c72152771e40c0b99bddc5cc6e4f50c7949a395346/ruff-0.17.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c673c170e27834d1262e3a9c1e97bdc9b9c3b180c63d89173ce69747232474c1", size = 10022543, upload-time = "2026-10-27T00:33:40.181Z" }, - { url = "https://files.pythonhosted.org/packages/73/c3/f90db547301080fcb82c92abf914c8bd57b89911d9b65a6c4cc6b52d0635/ruff-0.17.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6a754c0341bc9ca151b7b335988b3263921c08859f84ca219b70cee825571b6f", size = 10683921, upload-time = "2026-10-27T00:33:42.182Z" }, - { url = "https://files.pythonhosted.org/packages/e5/98/92d4a8a26c6c96cf1a5b34dd59036d8a71e52d650aab065c58867e964e63/ruff-0.17.3-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4590b9d86c0b1543ebb09094254e191cd43fe8edaf330baa035aab03da251532", size = 11373408, upload-time = "2026-10-27T00:33:44.19Z" }, - { url = "https://files.pythonhosted.org/packages/43/02/1f24d2e3064c9753926deeb901afa57777b37ee46799b09ddd7aee6e5145/ruff-0.17.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:bbde18beccd98c29a227c63c99022e3443b99258e08326df6425dfe0443705ef", size = 10977469, upload-time = "2026-10-27T00:33:46.179Z" }, - { url = "https://files.pythonhosted.org/packages/f0/20/fecedea2209f574ab92033b344e01a7f0c2dc76c6d6d19a14c9f8141173f/ruff-0.17.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7fa4b0f931cdbcb8a52044f370a3eb429fb42eb88807b0e800fcaa98dd42b24e", size = 10577491, upload-time = "2026-10-27T00:33:48.233Z" }, - { url = "https://files.pythonhosted.org/packages/33/36/b93fdf0bc6f84f0cd487aadfb0354deb40013669ea35ac3d26855de1e959/ruff-0.17.3-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:39405f341deec934b4289634324ad695f72df2970f9121582872eaf5b722f0f5", size = 10608748, upload-time = "2026-10-27T00:33:50.284Z" }, - { url = "https://files.pythonhosted.org/packages/5d/b7/7d3f5f14145daead1efb0b9a8289ed1daa100f419d60774375951723ce00/ruff-0.17.3-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:68074094f55ca3d29ab19491f640282f7a84061c4c7977aa5094b968ca457e9a", size = 10075057, upload-time = "2026-10-27T00:33:52.074Z" }, - { url = "https://files.pythonhosted.org/packages/b0/ed/93ff7a5909ee56e2bd4b982deae9e0efb2724417874a90c9e41ad66c6dd7/ruff-0.17.3-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:27bb571ac78fef178fe5118d2827df95c2aae74a48fff2b15f6acd03af5ff5bb", size = 10022431, upload-time = "2026-10-27T00:33:54.061Z" }, - { url = "https://files.pythonhosted.org/packages/9b/07/a83b9eeec8c1c3c0e4eda15f06c3a91001bfd2687ea2f07b750719bf9712/ruff-0.17.3-py3-none-musllinux_1_2_i686.whl", hash = "sha256:029c37cbd3de48ca37aa12117bead2d065f15da17d66bf84e0d4274013705db2", size = 10394903, upload-time = "2026-10-27T00:33:56.158Z" }, - { url = "https://files.pythonhosted.org/packages/af/b2/05c39857c2526fcbebe46ad93a8dc97424656dfef14d3ef933abe1ffd331/ruff-0.17.3-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:692fdb46d0fd9c71e380947dc5fc72f2c3f881073bc1f739e4579376231affbe", size = 10799780, upload-time = "2026-10-27T00:33:58.204Z" }, - { url = "https://files.pythonhosted.org/packages/ec/d9/47171a16739eb7a353936b31c20cf54340531e68c9af7d72fd7a784e235d/ruff-0.17.3-py3-none-win32.whl", hash = "sha256:46539cb031b01fd29ae0a02142483c46640b233ee12bb1c1b690bffa1555d5ca", size = 9908481, upload-time = "2026-10-27T00:34:00.087Z" }, - { url = "https://files.pythonhosted.org/packages/d0/a0/f08c1631bfd81faa6a90eaf70c37c786c11bed2046302b56bb506c25e1a0/ruff-0.17.3-py3-none-win_amd64.whl", hash = "sha256:56b8ffb3f3b3cbccb8b76b71b38261b7ed982ef5d20f5b447b1b61a7f4949b24", size = 10341333, upload-time = "2026-10-27T00:34:02.099Z" }, - { url = "https://files.pythonhosted.org/packages/99/d5/4ad4ed31413c301430918e70d3d38ae6f097af0766cb9ab8c9d502b2a4d6/ruff-0.17.3-py3-none-win_arm64.whl", hash = "sha256:81fce74bcd6be0e9da7c67c7553fd0f1f12964a2052cd728ef917b937a5ca1d9", size = 9854332, upload-time = "2026-10-27T00:34:03.847Z" }, +version = "0.17.5" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/86/cc/7b71512eb8b49926efb887cc66c74dd993642943c29eba51a877f6b85692/ruff-0.17.5.tar.gz", hash = "sha256:625e57d80cd43352d12ea81690f3eac46cddc8c0f35026d137fb0f157f94592e", size = 5368382, upload-time = "2026-11-12T17:54:55.04Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d4/f2/61df414cb4338617290a9023ad09486e207fb9a6d09357a7be34f2e369a4/ruff-0.17.5-py3-none-linux_armv6l.whl", hash = "sha256:d511dd302982e46a285528942fa6557d57730edc4bdb9def95e86a2603d77396", size = 10231309, upload-time = "2026-11-12T17:54:09.314Z" }, + { url = "https://files.pythonhosted.org/packages/d1/72/8ed970f3361f7c8d3f8e1b3b1af27cf086bc4b3a6b62ec20e21a1aaaaff5/ruff-0.17.5-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b72fbc232e328bdbb9cdddf4f1aedcd61bd1aa64d75fc012114b4add0bd7f26b", size = 10250018, upload-time = "2026-11-12T17:54:11.983Z" }, + { url = "https://files.pythonhosted.org/packages/dc/4b/8b10f6c9d0a18413301ae8dd2af9d180a81bb738b1b731d944a37404c523/ruff-0.17.5-py3-none-macosx_11_0_arm64.whl", hash = "sha256:6f0db748508f04a04e3fbebcc636a5c8b3bd76274f8ed28f497c44d75c2ea2d7", size = 9504737, upload-time = "2026-11-12T17:54:14.567Z" }, + { url = "https://files.pythonhosted.org/packages/b7/ea/1b3afa3943239dede7a0755ea139bdb51879f0f3f96f92894081d5c7d2e5/ruff-0.17.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6f6a7b138edf9cc402ca736a59d9525e6d766e5395760b72e7e146e6251ac963", size = 10168006, upload-time = "2026-11-12T17:54:17.195Z" }, + { url = "https://files.pythonhosted.org/packages/31/08/ee641daa45f83792f91274b65796cb011f1065f588911bfa3909ad9e31e7/ruff-0.17.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e52622ecf3a0df9d03e796fe3eed4aa085adda65520db7e0619cbd2192a97342", size = 10043751, upload-time = "2026-11-12T17:54:19.815Z" }, + { url = "https://files.pythonhosted.org/packages/f8/cf/1c59fdb42d0b5671ad5b160636fab4005ee28db72cb06aef6e3f3c04f377/ruff-0.17.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:54c0f67d1be11b55d12c184a819fc229f5eee3ef45c16c4fcad41258e83b4882", size = 10690562, upload-time = "2026-11-12T17:54:22.789Z" }, + { url = "https://files.pythonhosted.org/packages/49/c5/578074716173fb0c1591e9648a9f85c469888d9530cb35b89b757dc1208b/ruff-0.17.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dd0dfe7c6fe5a447fce467c58e69893be1d9a7e4378f5b9906432da33d94a97f", size = 11338465, upload-time = "2026-11-12T17:54:25.523Z" }, + { url = "https://files.pythonhosted.org/packages/aa/b9/d6428bcf5ed88f4dc1d6e3417ee350236ed36e7a35f9477b727c00e437bf/ruff-0.17.5-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ec4ecf40fb4d6e1265b009dbe551727920926fc0f769070c452d6d84b422a74d", size = 10895501, upload-time = "2026-11-12T17:54:28.441Z" }, + { url = "https://files.pythonhosted.org/packages/f2/8a/1e29c0c3785ae7e5cd0d54ee8717a08867ef71545796340be4c653c57e24/ruff-0.17.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:40ca8afaac309b41a5b2e09e4e7beb1f824826b93c25697c4d74f573324fba4e", size = 10613231, upload-time = "2026-11-12T17:54:30.862Z" }, + { url = "https://files.pythonhosted.org/packages/32/b6/88944350c14bb90651014d678ad554e233ae2a79c14ad52101845f93d15b/ruff-0.17.5-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:8e85601bd6d9b6c3e3b95c0e0dccdbac1d23c6bcef006d187fbcddaf8225a5df", size = 10562789, upload-time = "2026-11-12T17:54:33.869Z" }, + { url = "https://files.pythonhosted.org/packages/6f/fd/2792e955b0bf54295cdcdddc4bb3f380c0790d7e60e789f528a9e6e48a31/ruff-0.17.5-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:f93d2b7d449ed9545304f6923699ca20d13c675b69f258481709a08ae61076db", size = 10069824, upload-time = "2026-11-12T17:54:36.663Z" }, + { url = "https://files.pythonhosted.org/packages/07/9c/d7cad341b4c19237948a6dd1fcea1c9c39c9d08b70f22f0e157d1236ebd6/ruff-0.17.5-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0e5c125c5b31dc8efc948d41357496a4c4a312977565ccba740030efdff83580", size = 10038961, upload-time = "2026-11-12T17:54:39.452Z" }, + { url = "https://files.pythonhosted.org/packages/cc/a1/9cd0d4c371ddc70267d3bd557e718e2bdfb94c25e49d25605edfabb764bd/ruff-0.17.5-py3-none-musllinux_1_2_i686.whl", hash = "sha256:50dfc3c6b3ebd0a932f11dfd579bd42234b0b7137e68940eb6abdbfdb9d69697", size = 10385012, upload-time = "2026-11-12T17:54:41.808Z" }, + { url = "https://files.pythonhosted.org/packages/8f/a9/35f078ce98d4df318328ea5270382b5b65e680f7953b3db54f8e009c420c/ruff-0.17.5-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:86bd1f3b83c25f9b8055c6e796f0685b39d3127ce947322098c3108cf82fd586", size = 10793672, upload-time = "2026-11-12T17:54:44.342Z" }, + { url = "https://files.pythonhosted.org/packages/2c/a5/2e136dede2a88aaaf54498bbbdc81bc810f788ef6ef01efb97037d73cd1d/ruff-0.17.5-py3-none-win32.whl", hash = "sha256:e1546609b2ad73f1d6c5c076881b788672b7b3cc3283981182cbdbb6524ed88a", size = 9929908, upload-time = "2026-11-12T17:54:47.067Z" }, + { url = "https://files.pythonhosted.org/packages/ec/8c/e4db9ae1e0ee233c04df007ab6d0d42f799ae9abd95d352b6092ee7bc4bf/ruff-0.17.5-py3-none-win_amd64.whl", hash = "sha256:aa415d57c244299279901d776607fee3df7831c2a7435433fbfacde8632c6550", size = 10275454, upload-time = "2026-11-12T17:54:49.401Z" }, + { url = "https://files.pythonhosted.org/packages/e6/65/a1648bc1550e7683bf7bf1e2ce2485c9f8535cbca6cca9ec7b73cc12fb8e/ruff-0.17.5-py3-none-win_arm64.whl", hash = "sha256:64a6fd668a336df959c522991de33e9e3c8be463afc0c9ac8f029f9d19ef756e", size = 9849020, upload-time = "2026-11-12T17:54:52.055Z" }, ] [[package]] @@ -2290,7 +2290,7 @@ wheels = [ [[package]] name = "typer" -version = "0.27.3" +version = "0.28.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "annotated-doc" }, @@ -2298,9 +2298,9 @@ dependencies = [ { name = "rich" }, { name = "shellingham" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/03/51/d33db42cc72ffd8c30777547b42d01f0cbf9d95a770457698d0174b3ed71/typer-0.27.3.tar.gz", hash = "sha256:d0396f770a560ab1b0a8504e13b5f254b728cedb05c61cf0359e944e50ce8901", size = 205303, upload-time = "2026-10-06T17:24:16.61Z" } +sdist = { url = "https://files.pythonhosted.org/packages/ad/8f/21021859316f44289101638dc74d82e13d722d8533e4b8708a3ab7c8461a/typer-0.28.0.tar.gz", hash = "sha256:69ab84ef79fd601cff071bbd2566d855ecadfd93adbc4b3360b9924359bdd857", size = 205415, upload-time = "2026-11-06T08:37:19.779Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/07/ea/2e31b67051e91a133189e9c000c222502ddc6969856416de0d095de4c0b0/typer-0.27.3-py3-none-any.whl", hash = "sha256:e50022f28b82a86313e54501317a1db64bf8f8d036ff8cfe5ca7e47675454aff", size = 123312, upload-time = "2026-10-06T17:24:15.054Z" }, + { url = "https://files.pythonhosted.org/packages/19/98/8ef60c7cd773dbab9d276a4c7bff505913a25b61acd8a9ef01ceeb70f554/typer-0.28.0-py3-none-any.whl", hash = "sha256:afd18929180b706c5e9a239f53c3c8136903553c0c2d460598bbaa924191d4ab", size = 123253, upload-time = "2026-11-06T08:37:18.611Z" }, ] [[package]]