Skip to content

Commit

Permalink
Fix isinstance test on null values (#192)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Adams <[email protected]>
  • Loading branch information
cybermaggedon and Mark Adams authored Dec 4, 2024
1 parent 5770af5 commit e3d06ab
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions trustgraph-base/trustgraph/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,20 @@ def triples_query(self, s=None, p=None, o=None, limit=10000):
"limit": limit
}

if not isinstance(s, Uri):
raise RuntimeError("s must be Uri")
if not isinstance(p, Uri):
raise RuntimeError("p must be Uri")
if not isinstance(o, Uri) and not isinstance(o, Literal):
raise RuntimeError("o must be Uri or Literal")

if s: input["s"] = { "v": str(s), "e": isinstance(s, Uri), }
if p: input["p"] = { "v": str(p), "e": isinstance(p, Uri), }
if o: input["o"] = { "v": str(o), "e": isinstance(o, Uri), }
if s:
if not isinstance(s, Uri):
raise RuntimeError("s must be Uri")
input["s"] = { "v": str(s), "e": isinstance(s, Uri), }

if p:
if not isinstance(p, Uri):
raise RuntimeError("p must be Uri")
input["p"] = { "v": str(p), "e": isinstance(p, Uri), }

if o:
if not isinstance(o, Uri) and not isinstance(o, Literal):
raise RuntimeError("o must be Uri or Literal")
input["o"] = { "v": str(o), "e": isinstance(o, Uri), }

url = f"{self.url}triples-query"

Expand Down

0 comments on commit e3d06ab

Please sign in to comment.