RDFLib / rdflib

RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.
https://rdflib.readthedocs.org
BSD 3-Clause "New" or "Revised" License
2.15k stars 555 forks source link

In .patch serializer, default to "add" operation if no operation #2898

Closed ashleysommer closed 1 month ago

ashleysommer commented 1 month ago

In RDF .patch serializer, default to "add" operation if no operation or no target (diff) is given in kwargs. This is because not all serializing codepaths allow passing kwargs.

This fixes the testsuite integration and allows round-trip tests to complete successfully with the .patch serializer.

I believe it is reasonable to expect that a user naively serializing their Graph to .patch format would want to default to add operation if no operation is given. In current implementation, no operation and no target results in a .patch file with only a header and no contents. This is considered a no-op file, and is likely not what the user wants.

Fixes the issue discussed at the bottom of #2877