Skip to content

Commit

Permalink
Merge branch 'main' into issue/namespace_overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholascar authored Aug 1, 2024
2 parents c032de8 + fd10835 commit bc6aec1
Show file tree
Hide file tree
Showing 38 changed files with 1,667 additions and 395 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ updates:
versions:
- 3.4.3
- 3.5.2
# We only use setuptools for a couple of things in the test suite
# There is no need to keep it bleeding-edge. There are too frequent
# updates to setuptools, requires too much maintenance to keep it up to date.
- dependency-name: setuptools
versions:
- ">=72.0"
- dependency-name: types-setuptools
versions:
- ">=72.0"
# Ignore all black updates, because we use a pinned version we don't want to change
- dependency-name: black
# Ignore types-setuptools patch-level updates, because they issue too many!
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ The stable release of RDFLib may be installed with Python's package management t

Some features of RDFLib require optional dependencies which may be installed using *pip* extras:

$ pip install rdflib[berkeleydb,networkx,html,lxml]
$ pip install rdflib[berkeleydb,networkx,html,lxml,orjson]

Alternatively manually download the package from the Python Package
Index (PyPI) at https://pypi.python.org/pypi/rdflib
Expand Down
1 change: 1 addition & 0 deletions devtools/constraints.min
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ berkeleydb==18.1.2
networkx==2.0
html5lib==1.0.1
lxml==4.3.0
orjson==3.9.14
2 changes: 1 addition & 1 deletion docker/latest/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/library/python:3.12.4-slim@sha256:52f92c54e879539342692d20a4bea99516d4a2eb3cd16dfbb4e4b964aa8becaa
FROM docker.io/library/python:3.12.4-slim@sha256:740d94a19218c8dd584b92f804b1158f85b0d241e5215ea26ed2dcade2b9d138

COPY docker/latest/requirements.txt /var/tmp/build/

Expand Down
2 changes: 1 addition & 1 deletion docker/unstable/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/library/python:3.12.4-slim@sha256:52f92c54e879539342692d20a4bea99516d4a2eb3cd16dfbb4e4b964aa8becaa
FROM docker.io/library/python:3.12.4-slim@sha256:740d94a19218c8dd584b92f804b1158f85b0d241e5215ea26ed2dcade2b9d138

# This file is generated from docker:unstable in Taskfile.yml
COPY var/requirements.txt /var/tmp/build/
Expand Down
107 changes: 84 additions & 23 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ berkeleydb = {version = "^18.1.0", optional = true}
networkx = {version = ">=2,<4", optional = true}
html5lib = {version = "^1.0", optional = true}
lxml = {version = ">=4.3,<6.0", optional = true}
orjson = {version = ">=3.9.14,<4", optional = true}

[tool.poetry.group.dev.dependencies]
black = "24.4.2"
Expand All @@ -67,13 +68,14 @@ sphinx-autodoc-typehints = ">=1.25.3,<=2.0.1"
typing-extensions = "^4.5.0"

[tool.poetry.group.lint.dependencies]
ruff = ">=0.0.286,<0.5.5"
ruff = ">=0.0.286,<0.6.0"

[tool.poetry.extras]
berkeleydb = ["berkeleydb"]
networkx = ["networkx"]
html = ["html5lib"]
lxml = ["lxml"]
orjson = ["orjson"]

[build-system]
requires = ["poetry-core>=1.4.0"]
Expand Down
11 changes: 10 additions & 1 deletion rdflib/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ class Collection:
True
>>> c.index(Literal(2)) == 1
True
The collection is immutable if ``uri`` is the empty list
(``http://www.w3.org/1999/02/22-rdf-syntax-ns#nil``).
"""

def __init__(self, graph: Graph, uri: Node, seq: List[Node] = []):
self.graph = graph
self.uri = uri or BNode()
self += seq
if seq:
self += seq

def n3(self) -> str:
"""
Expand Down Expand Up @@ -232,6 +236,9 @@ def append(self, item: Node) -> Collection:
"""

end = self._end()
if end == RDF.nil:
raise ValueError("Cannot append to empty list")

if (end, RDF.first, None) in self.graph:
# append new node to the end of the linked list
node = BNode()
Expand All @@ -244,6 +251,8 @@ def append(self, item: Node) -> Collection:

def __iadd__(self, other: Iterable[Node]):
end = self._end()
if end == RDF.nil:
raise ValueError("Cannot append to empty list")
self.graph.remove((end, RDF.rest, None))

for item in other:
Expand Down
Loading

0 comments on commit bc6aec1

Please sign in to comment.