rdflib icon indicating copy to clipboard operation
rdflib copied to clipboard

`rdflib.graph.ConjunctiveGraph.parse` should return `self`

Open aucampia opened this issue 1 year ago • 4 comments

Currently, rdflib.graph.ConjunctiveGraph.parse returns context instead of self, which seems wrong:

https://github.com/RDFLib/rdflib/blob/5c3c78af33530298a7db2350304ce253370e91c1/rdflib/graph.py#L2250-L2251

It also causes confusion for users because it is not really something anyone would expect to happen, see https://github.com/RDFLib/rdflib/issues/2335.

aucampia avatar Apr 11 '23 21:04 aucampia

@sdasda7777 Made this to track the issue, it is probably also fairly simple to fix, just maybe a bit controversial.

aucampia avatar Apr 11 '23 21:04 aucampia

Can I claim the PR I submitted the change is my first contribution so not sure how it goes. Let me know if there are any faults. Thanks :)

Sirjan-Singh avatar Apr 11 '23 21:04 Sirjan-Singh

It is certainly a problematic design. However, it has been behaving like that for many years (since the inception AFAIK, so for a decade or more?).

Changing it would require at least a major version bump, formally, and IMO major version bumps aren't enough in these situations, since such a change would not break existing code (which is actually OK for a major version change), but change behaviour in possibly subtle ways. Arguably code in the wild might behave subtly wrong right now due to this problematic design, but how do we know? I'd say, for a major change striving for a uniform API. deprecate ConjunctiveGraph and shape up Dataset to be fully standards-compliant (barring any semantic changes in RDF 1.2).

(It could be argued that all these odd nuances in RDFLib, which are slowly changing, causing possible subtle changes in production code, calls for an "RDFLib 2". Of course, such a debate has happened before.)

niklasl avatar Apr 12 '23 06:04 niklasl

@Sirjan-Singh real sorry - I thought this was a recent problem, but @niklasl is right, the code in question is 18 years old. We can maybe say that it was a bug, but if it has been the interface for 18 years we can't change it without a major version bump, and for the next RDFLib interface we will first build it in rdflib/v7/_provisional.

aucampia avatar Apr 12 '23 20:04 aucampia