Proposal: rename "Structure and dependencies" discussion category to "Development" #2027
Replies: 3 comments 3 replies
-
I'm down with this. After you raised the LSP violations issue, I've been minded to propose something similar and promote the LSP violation issue into a sub-discussion of development because, on reflection, from a domain modelling perspective, it makes no sense for ATM, I'm working my way through the |
Beta Was this translation helpful? Give feedback.
-
Also, it'd be useful to have somewhere to punt speculative work ... Also, in other, as-yet-unexposed-and-incomplete work, I have adapted some of the (rather good) code in Pilon & Carrothers's apparently-abandoned “pymantic” to create a unified set of lark-based RDF parsers for RDFLib. Thus far I have completed hext, ntriples, nquads and turtle for standard RDF and ntriples/nquads for RDF Star. With the 3 standard RDF parsers, I'm seeing 100% scores on the w3 test suite. I note that RDFLib's N3 parser explicitly extends RDF, so it's up for discussion as to whether this set of lark-based parsers should be published as a plugin or migrated into the main RDFLib codebase. |
Beta Was this translation helpful? Give feedback.
-
Pymantic demonstrates some interesting (to me, at least) alternative approaches to modelling the domain and I'm minded to suggest that RDFLib might benefit from shifting its model slightly to encompass some of pymantic's approach if it's generally perceived to be of benefit. F'rinstance while RDFLib is rich in modelling RDF terms, it doesn't offer a specific model for statements, so I've been riffing off've P&G's from dataclasses import (
dataclass,
FrozenInstanceError,
asdict,
fields,
astuple,
replace,
)
@dataclass(order=True, frozen=True)
class Triple:
subject: Optional[Node] = None
predicate: Optional[Node] = None
object: Optional[Node] = None
def __str__(self):
return str(self.subject) + " " + str(self.predicate) + " " + str(self.object)
def toString(self): # noqa: N802
return str(self)
def __reduce__(self):
return (Triple, (self.subject, self.predicate, self.object))
def toPython(self): # noqa: N802
return (
self.subject.toPython(),
self.predicate.toPython(),
self.object.toPython(),
)
def test_triple():
t = Triple()
assert isinstance(t, Triple)
logger.debug(f"{Triple.__class__}")
def test_triple_args():
t = Triple(tarek, likes, pizza)
assert isinstance(t, Triple)
assert t.subject == tarek
assert t.predicate == likes
assert t.__hash__() is not None
with pytest.raises(FrozenInstanceError, match="cannot assign to field 'subject'"):
t.subject = michel
assert str(t) == "urn:example:tarek urn:example:likes urn:example:pizza"
assert t.toPython() == (
"urn:example:tarek",
"urn:example:likes",
"urn:example:pizza",
)
assert asdict(t) == {
"object": rdflib.term.URIRef("urn:example:pizza"),
"predicate": rdflib.term.URIRef("urn:example:likes"),
"subject": rdflib.term.URIRef("urn:example:tarek"),
}
t = replace(t, subject=michel)
assert t.subject == michel |
Beta Was this translation helpful? Give feedback.
-
We need some place to discuss development related issues and "Structure and dependencies" is close enough but not quite there. Specifically I want something broad enough to cover contribution guidelines, use of conventional commits, architecture etc.
Please vote using thumbs up/down reactions on this topic:
Beta Was this translation helpful? Give feedback.
All reactions