diff options
| author | Iwan Aucamp <aucampia@gmail.com> | 2023-03-26 12:53:29 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-26 12:53:29 +0200 |
| commit | 57bb42886b57a37f1ba93a4d1b52651d978d049c (patch) | |
| tree | ac75957fa29dc49c39618b01fcc9dda29bcb4ea9 /rdflib | |
| parent | 4da67f9a17ffe8fa128afcdd2259e337bccafaa3 (diff) | |
| download | rdflib-57bb42886b57a37f1ba93a4d1b52651d978d049c.tar.gz | |
fix: restore the 6.1.1 default bound namespaces (#2313)
The namespaces bound by default by `rdflib.graph.Graph` and
`rdflib.namespace.NamespaceManager` was reduced in version 6.2.0 of RDFLib,
however, this also would cause code that worked with 6.1.1 to break, so this
constituted a breaking change. This change restores the previous behaviour,
binding the same namespaces as was bound in 6.1.1.
To bind a reduced set of namespaces, the `bind_namespaces` parameter of
`rdflib.graph.Graph` or `rdflib.namespace.NamespaceManager` can be used.
- Closes <https://github.com/RDFLib/rdflib/issues/2103>.
Diffstat (limited to 'rdflib')
| -rw-r--r-- | rdflib/graph.py | 2 | ||||
| -rw-r--r-- | rdflib/namespace/__init__.py | 15 |
2 files changed, 13 insertions, 4 deletions
diff --git a/rdflib/graph.py b/rdflib/graph.py index 7d32ab38..4a96e6d3 100644 --- a/rdflib/graph.py +++ b/rdflib/graph.py @@ -437,7 +437,7 @@ class Graph(Node): identifier: Optional[Union[_ContextIdentifierType, str]] = None, namespace_manager: Optional[NamespaceManager] = None, base: Optional[str] = None, - bind_namespaces: "_NamespaceSetString" = "core", + bind_namespaces: "_NamespaceSetString" = "rdflib", ): super(Graph, self).__init__() self.base = base diff --git a/rdflib/namespace/__init__.py b/rdflib/namespace/__init__.py index fb6d845b..c88fdedd 100644 --- a/rdflib/namespace/__init__.py +++ b/rdflib/namespace/__init__.py @@ -360,13 +360,13 @@ class NamespaceManager(object): * core: * binds several core RDF prefixes only * owl, rdf, rdfs, xsd, xml from the NAMESPACE_PREFIXES_CORE object - * this is default * rdflib: * binds all the namespaces shipped with RDFLib as DefinedNamespace instances * all the core namespaces and all the following: brick, csvw, dc, dcat * dcmitype, dcterms, dcam, doap, foaf, geo, odrl, org, prof, prov, qb, schema * sh, skos, sosa, ssn, time, vann, void * see the NAMESPACE_PREFIXES_RDFLIB object for the up-to-date list + * this is default * none: * binds no namespaces to prefixes * note this is NOT default behaviour @@ -374,6 +374,14 @@ class NamespaceManager(object): * using prefix bindings from prefix.cc which is a online prefixes database * not implemented yet - this is aspirational + .. attention:: + + The namespaces bound for specific values of ``bind_namespaces`` + constitute part of RDFLib's public interface, so changes to them should + only be additive within the same minor version. Removing values, or + removing namespaces that are bound by default, constitutes a breaking + change. + See the Sample usage @@ -390,10 +398,11 @@ class NamespaceManager(object): >>> all_ns = [n for n in g.namespace_manager.namespaces()] >>> assert ('ex', rdflib.term.URIRef('http://example.com/')) in all_ns >>> - """ - def __init__(self, graph: "Graph", bind_namespaces: "_NamespaceSetString" = "core"): + def __init__( + self, graph: "Graph", bind_namespaces: "_NamespaceSetString" = "rdflib" + ): self.graph = graph self.__cache: Dict[str, Tuple[str, URIRef, str]] = {} self.__cache_strict: Dict[str, Tuple[str, URIRef, str]] = {} |
