Changes to graph.serialize() by ashleysommer · Pull Request #1183 · RDFLib/rdflib (original) (raw)

This is part of our work to simplify and modernize the methods on rdflib.Graph to clean up the API surface of the Graph.

These are some long-overdue changes to serialize(). This is a slightly breaking change, so will be coming as part of RDFLib 6.0.0, but is done in such a way as to minimize breakage as much as possible.

These changes are:

  1. Change default format from 'xml' to 'turtle'
  2. If serialize() destination=None and encoding=None, output is a str, not bytes
  3. Add a new convenience method to print the Graph contents (turtle by default)

Lots of fixes in tests to adapt to these changes (serialize is used a lot to check graph state in tests).
Blacked files which were involved in this change.