-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
data modelRelated to the hermes data modelRelated to the hermes data modelhelp wantedExtra attention is neededExtra attention is needed
Description
While testing ld_list in #418 we found some potential issues:
- Sets and graphs are not dictionaries with
"@set"or"@graph"as keys for their list of items in their expanded JSON-LD form. But the constructor of andis_ld_listfromld_listassume it otherwise (is_containerofld_listhas the same flaws) and the conversion from a ld_list withcontainer = "@set"to expanded json gives the wrong form:{"https://schema.org/name": {"@set": ["a", "b"]}}'s expanded version is[{"https://schema.org/name": [{"@value": "a"}, {"@value": "b}]}].is_ld_list([{"@set": ["a", "b"]}])andis_ld_list([{"@set": [{"@value": "a"}, {"@value": "b}]}])returnTruebutis_ld_list([{"@value": "a"}, {"@value": "b}])returnsFalseld_list([{"@set": [{"@value": "a"}, {"@value": "b}]}])returns the correct object butld_list([{"@set": ["a", "b"]}])creates a non expanded ld_list andld_list([{"@value": "a"}, {"@value": "b}])raises aValueErrorld_list.from_list(["a", "b"], container="@set", key="https://schema.org/name", context={"schema": "https://schema.org/"}).ld_valueis[{"@set": [{"@value": "a"}, {"@value": "b}]}]instead of[{"@value": "a"}, {"@value": "b}]}]
- Should a list containing a single value (a dictionary) be considered an expanded set/ graph or just as a expanded JSON-LD dict if it isn't a value or id? This is relevant for e.g. setting or appending such an object (for example
[{"schema:name": "foo"}]) but also forld_dict. - JSON-LD supports nested containers. But the type of those makes a difference which is not considered in
__setitem__andappendofld_list. For example:- A set inside a set gets unpacked but a set inside a list gets turned into a list when expanded.
[{"https://schema.org/name": [{"@set": [{"@value": "a"}, {"@set": ["b", "c"]}, {"@list": ["d", "e"]}]}]}]'s expanded from is[{"https://schema.org/name": [{"@value": "a"}, {"@value": "b"}, {"@value": "c"}, {"@list": [{"@value": "d"}, {"@value": "e"}]}]}][{"https://schema.org/name": [{"@list": [{"@value": "a"}, {"@set": ["b", "c"]}, {"@list": ["d", "e"]}]}]}]'s expanded from is[{"https://schema.org/name": [{"@list": [{"@value": "a"}, {"@list": [{"@value": "b"}, {"@value": "c"}]}, {"@list": [{ "@value": "d"}, {"@value": "e"}]}]}]}].
- Should parent, key, index and context be also compared when comparing two ld_lists with
==through__eq__or with!=through__ne__? At the moment only the itemlistand the container type areis compared.And should the order be ignored for ld_lists with container type "@set"? -
__init__documents a parameter that does not exist.
Metadata
Metadata
Assignees
Labels
data modelRelated to the hermes data modelRelated to the hermes data modelhelp wantedExtra attention is neededExtra attention is needed