Skip to content

Commit

Permalink
fixing MyPy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholascar committed Dec 9, 2021
1 parent 0891e2e commit dabcacf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions rdflib/plugins/parsers/hext.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ def _load_json_line(self, line: str):
return [x if x != "" else None for x in json.loads(line)]

def _parse_hextuple(self, cg: ConjunctiveGraph, tup: List[Union[str, None]]):
# all values check
# subject, predicate, value, datatype cannot be None
# language and graph may be None
if tup[0] is None or tup[1] is None or tup[2] is None or tup[3] is None:
raise ValueError("subject, predicate, value, datatype cannot be None")

# 1 - subject
s: Union[URIRef, BNode]
if tup[0].startswith("_"):
s = BNode(value=tup[0].replace("_:", ""))
else:
Expand All @@ -37,6 +44,7 @@ def _parse_hextuple(self, cg: ConjunctiveGraph, tup: List[Union[str, None]]):
p = URIRef(tup[1])

# 3 - value
o: Union[URIRef, BNode, Literal]
if tup[3] == "globalId":
o = URIRef(tup[2])
elif tup[3] == "localId":
Expand Down
2 changes: 1 addition & 1 deletion rdflib/plugins/serializers/hext.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class HextuplesSerializer(Serializer):

def __init__(self, store: Union[Graph, ConjunctiveGraph]):
self.default_context: Optional[Node]
if type(store) != Graph:
if isinstance(store, ConjunctiveGraph):
self.contexts = list(store.contexts())
if store.default_context:
self.default_context = store.default_context
Expand Down

0 comments on commit dabcacf

Please sign in to comment.