Changeset - 165fc8ed28ab
[Not reviewed]
default
0 2 0
drewp@bigasterisk.com - 20 months ago 2023-05-23 23:26:32
drewp@bigasterisk.com
clearly this approach is wrong
2 files changed with 5 insertions and 0 deletions:
0 comments (0 inline, 0 general)
light9/typedgraph.py
Show inline comments
 
@@ -69,12 +69,14 @@ def typedValue(objType: Type[_ObjType], 
 

	
 
    ConvFrom: Type[Node] = type(obj)
 
    ConvTo = 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:
 
            conv = _convLiteral(objType, cast(Literal, obj))
 
        else:
 
            raise ConversionError
light9/typedgraph_test.py
Show inline comments
 
@@ -46,12 +46,15 @@ class TestTypeIncludes:
 

	
 
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'])
 

	
 
    def test_getsBNodeAsNode(self):
 
        assert typedValue(Node, g, subj, L9['bnode']) == g.value(subj,  L9['bnode'])
0 comments (0 inline, 0 general)