changeset 2219:165fc8ed28ab

clearly this approach is wrong
author drewp@bigasterisk.com
date Tue, 23 May 2023 16:26:32 -0700
parents 436a1fdbfe4a
children e6ae7bfc12f2
files light9/typedgraph.py light9/typedgraph_test.py
diffstat 2 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/light9/typedgraph.py	Tue May 23 15:52:26 2023 -0700
+++ b/light9/typedgraph.py	Tue May 23 16:26:32 2023 -0700
@@ -72,6 +72,8 @@
     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:
--- a/light9/typedgraph_test.py	Tue May 23 15:52:26 2023 -0700
+++ b/light9/typedgraph_test.py	Tue May 23 16:26:32 2023 -0700
@@ -49,6 +49,9 @@
     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'])