# HG changeset patch # User drewp@bigasterisk.com # Date 2023-05-23 23:26:32 # Node ID 165fc8ed28ab2d64937e8ac0c0ef47283c6d23e9 # Parent 436a1fdbfe4a41f55ee90647f96a97bb76534838 clearly this approach is wrong diff --git a/light9/typedgraph.py b/light9/typedgraph.py --- a/light9/typedgraph.py +++ b/light9/typedgraph.py @@ -72,6 +72,8 @@ def typedValue(objType: Type[_ObjType], try: if ConvFrom == URIRef and _typeIncludes(ConvTo, URIRef): conv = obj + elif ConvFrom == URIRef and issubclass(URIRef, ConvTo) and not issubclass(str, ConvTo): # rewrite please + conv = obj elif ConvFrom == BNode and issubclass(BNode, ConvTo): conv = obj elif ConvFrom == Literal: diff --git a/light9/typedgraph_test.py b/light9/typedgraph_test.py --- a/light9/typedgraph_test.py +++ b/light9/typedgraph_test.py @@ -49,6 +49,9 @@ class TestTypedValueReturnsBasicTypes: def test_getsUri(self): assert typedValue(URIRef, g, subj, L9['uri']) == L9['c'] + def test_getsAsNode(self): + assert typedValue(Node, g, subj, L9['uri']) == L9['c'] + def test_getsBNode(self): # this is unusual usage since users ought to always be able to replace BNode with URIRef assert typedValue(BNode, g, subj, L9['bnode']) == g.value(subj, L9['bnode'])