Skip to content

Commit 46f3a05

Browse files
Separated base_iri argument from triplestore_url in rdflib backend (#49)
* Separated `base_iri` argument from `triplestore_url` in rdflib. * Before gave rdflib the `base_iri` argument an additional meaning not documented in Triplestore.__init__(). This is now sorted out. * Issue a warning about unused arguments as suggested by reviewer Co-authored-by: Casper Welzel Andersen <43357585+CasperWA@users.noreply.github.com>
1 parent f1039cb commit 46f3a05

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

tripper/backends/rdflib.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from rdflib.util import guess_format
2121

2222
from tripper import Literal
23+
from tripper.utils import UnusedArgumentWarning
2324

2425
if TYPE_CHECKING: # pragma: no cover
2526
from collections.abc import Sequence
@@ -49,12 +50,11 @@ class RdflibStrategy:
4950
"""Triplestore strategy for rdflib.
5051
5152
Arguments:
52-
base_iri: If given, initialise the triplestore from this storage.
53-
When `close()` is called, the storage will be overwritten
54-
with the current content of the triplestore.
53+
base_iri: Unused by this backend.
5554
database: Unused - rdflib does not support multiple databases.
56-
triplestore_url: Alternative URL to the underlying ontology if
57-
`base_iri` is not resolvable. Defaults to `base_iri`.
55+
triplestore_url: If given, initialise the triplestore from this
56+
storage. When `close()` is called, the storage will be
57+
overwritten with the current content of the triplestore.
5858
format: Format of storage specified with `base_iri`.
5959
"""
6060

@@ -65,10 +65,13 @@ def __init__(
6565
triplestore_url: "Optional[str]" = None,
6666
format: "Optional[str]" = None, # pylint: disable=redefined-builtin
6767
) -> None:
68-
# pylint: disable=unused-argument
68+
if base_iri:
69+
warnings.warn("base_iri", UnusedArgumentWarning, stacklevel=2)
70+
if database:
71+
warnings.warn("database", UnusedArgumentWarning, stacklevel=2)
72+
6973
self.graph = Graph()
70-
self.base_iri = base_iri
71-
self.triplestore_url = triplestore_url if triplestore_url else base_iri
74+
self.triplestore_url = triplestore_url
7275
if self.triplestore_url is not None:
7376
if format is None:
7477
format = guess_format(self.triplestore_url)

tripper/utils.py

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
Triple = Tuple[str, str, Union[str, Literal]]
1919

2020

21+
class UnusedArgumentWarning(Warning):
22+
"""Argument is unused."""
23+
24+
2125
def infer_iri(obj):
2226
"""Return IRI of the individual that stands for object `obj`."""
2327
if isinstance(obj, str):

0 commit comments

Comments
 (0)