Skip to content

Commit fb43b7a

Browse files
authored
set default jsonld version to 1.1. autoformat for corresponding files. (#2751)
Co-authored-by: WhiteGobo <richardfechner@posteo.net>
1 parent a54b63a commit fb43b7a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

rdflib/plugins/parsers/jsonld.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ class JsonLDParser(rdflib.parser.Parser):
7979
def __init__(self):
8080
super(JsonLDParser, self).__init__()
8181

82-
def parse(self, source: InputSource, sink: Graph, **kwargs: Any) -> None:
82+
def parse(
83+
self, source: InputSource, sink: Graph, version: float = 1.1, **kwargs: Any
84+
) -> None:
8385
# TODO: docstring w. args and return value
8486
encoding = kwargs.get("encoding") or "utf-8"
8587
if encoding not in ("utf-8", "utf-16"):
@@ -99,9 +101,9 @@ def parse(self, source: InputSource, sink: Graph, **kwargs: Any) -> None:
99101
context_data = context_from_urlinputsource(source)
100102

101103
try:
102-
version = float(kwargs.get("version", "1.0"))
104+
version = float(version)
103105
except ValueError:
104-
version = None
106+
version = 1.1
105107

106108
generalized_rdf = kwargs.get("generalized_rdf", False)
107109

@@ -401,7 +403,9 @@ def _parse_container(
401403
(
402404
dict({GRAPH: o})
403405
if k in context.get_keys(NONE)
404-
else dict({ID: k, GRAPH: o}) if isinstance(o, dict) else o
406+
else dict({ID: k, GRAPH: o})
407+
if isinstance(o, dict)
408+
else o
405409
)
406410
for k, o in obj.items()
407411
]

rdflib/plugins/shared/jsonld/context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ def __init__(
7878
self,
7979
source: _ContextSourceType = None,
8080
base: Optional[str] = None,
81-
version: Optional[float] = None,
81+
version: Optional[float] = 1.1,
8282
):
83-
self.version: float = version or 1.0
83+
self.version: float = version or 1.1
8484
self.language = None
8585
self.vocab: Optional[str] = None
8686
self._base: Optional[str]

0 commit comments

Comments
 (0)