Skip to content

Commit 31ddb93

Browse files
authored
Merge branch 'main' into main
2 parents fe6e6fd + 6747715 commit 31ddb93

21 files changed

+471
-268
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
ci:
33
# https://pre-commit.ci/#configuration
4-
autoupdate_schedule: weekly
4+
autoupdate_schedule: quarterly
55
autofix_prs: false
66

77
# https://pre-commit.com/#adding-pre-commit-plugins-to-your-project
88
repos:
99
- repo: https://github.com/astral-sh/ruff-pre-commit
1010
# WARNING: Ruff version should be the same as in `pyproject.toml`
11-
rev: v0.7.1
11+
rev: v0.7.2
1212
hooks:
1313
- id: ruff
1414
args: ["--fix"]

devtools/requirements-poetry.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Fixing this here as readthedocs can't use the compiled requirements-poetry.txt
22
# due to conflicts.
3-
poetry==1.8.4
3+
poetry==1.8.5

docker/latest/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM docker.io/library/python:3.13.0-slim@sha256:2ec5a4a5c3e919570f57675471f081d6299668d909feabd8d4803c6c61af666c
1+
FROM docker.io/library/python:3.13.1-slim@sha256:1127090f9fff0b8e7c3a1367855ef8a3299472d2c9ed122948a576c39addeaf1
22

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

docker/unstable/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM docker.io/library/python:3.13.0-slim@sha256:751d8bece269ba9e672b3f2226050e7e6fb3f3da3408b5dcb5d415a054fcb061
1+
FROM docker.io/library/python:3.13.1-slim@sha256:1127090f9fff0b8e7c3a1367855ef8a3299472d2c9ed122948a576c39addeaf1
22

33
# This file is generated from docker:unstable in Taskfile.yml
44
COPY var/requirements.txt /var/tmp/build/

docs/developers.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,20 +231,17 @@ our black.toml config file:
231231
232232
poetry run black .
233233
234-
Check style and conventions with `flake8 <https://flake8.pycqa.org/en/latest/>`_:
234+
Check style and conventions with `ruff <https://docs.astral.sh/ruff/linter/>`_:
235235

236236
.. code-block:: bash
237237
238-
poetry run flake8 rdflib
238+
poetry run ruff check
239239
240-
We also provide a `flakeheaven <https://pypi.org/project/flakeheaven/>`_
241-
baseline that ignores existing flake8 errors and only reports on newly
242-
introduced flake8 errors:
240+
Any issues that are found can potentially be fixed automatically using:
243241

244242
.. code-block:: bash
245243
246-
poetry run flakeheaven
247-
244+
poetry run ruff check --fix
248245
249246
Check types with `mypy <http://mypy-lang.org/>`_:
250247

poetry.lock

Lines changed: 171 additions & 154 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pytest-cov = ">=4,<7"
6363
coverage = {version = "^7.0.1", extras = ["toml"]}
6464
types-setuptools = ">=68.0.0.3,<72.0.0.0"
6565
setuptools = ">=68,<72"
66-
wheel = ">=0.42,<0.45"
66+
wheel = ">=0.42,<0.46"
6767

6868
[tool.poetry.group.docs.dependencies]
6969
sphinx = ">=7.1.2,<8"
@@ -73,7 +73,7 @@ sphinx-autodoc-typehints = ">=2.3.0,<2.4.0"
7373
typing-extensions = "^4.11.0"
7474

7575
[tool.poetry.group.lint.dependencies]
76-
ruff = ">=0.7.1,<0.8.0"
76+
ruff = ">=0.7.2,<1"
7777

7878
[tool.poetry.extras]
7979
berkeleydb = ["berkeleydb"]

rdflib/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"BNode",
6060
"IdentifiedNode",
6161
"Literal",
62+
"Node",
6263
"Variable",
6364
"Namespace",
6465
"Dataset",
@@ -195,7 +196,7 @@
195196
XSD,
196197
Namespace,
197198
)
198-
from rdflib.term import BNode, IdentifiedNode, Literal, URIRef, Variable
199+
from rdflib.term import BNode, IdentifiedNode, Literal, Node, URIRef, Variable
199200

200201
from rdflib import plugin, query, util # isort:skip
201202
from rdflib.container import * # isort:skip # noqa: F403

rdflib/graph.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -966,19 +966,19 @@ def triples_choices(
966966
self,
967967
triple: (
968968
tuple[
969-
list[_SubjectType] | tuple[_SubjectType],
969+
list[_SubjectType] | tuple[_SubjectType, ...],
970970
_PredicateType,
971971
_ObjectType | None,
972972
]
973973
| tuple[
974974
_SubjectType | None,
975-
list[_PredicateType] | tuple[_PredicateType],
975+
list[_PredicateType] | tuple[_PredicateType, ...],
976976
_ObjectType | None,
977977
]
978978
| tuple[
979979
_SubjectType | None,
980980
_PredicateType,
981-
list[_ObjectType] | tuple[_ObjectType],
981+
list[_ObjectType] | tuple[_ObjectType, ...],
982982
]
983983
),
984984
context: _ContextType | None = None,
@@ -2208,19 +2208,19 @@ def triples_choices(
22082208
self,
22092209
triple: (
22102210
tuple[
2211-
list[_SubjectType] | tuple[_SubjectType],
2211+
list[_SubjectType] | tuple[_SubjectType, ...],
22122212
_PredicateType,
22132213
_ObjectType | None,
22142214
]
22152215
| tuple[
22162216
_SubjectType | None,
2217-
list[_PredicateType] | tuple[_PredicateType],
2217+
list[_PredicateType] | tuple[_PredicateType, ...],
22182218
_ObjectType | None,
22192219
]
22202220
| tuple[
22212221
_SubjectType | None,
22222222
_PredicateType,
2223-
list[_ObjectType] | tuple[_ObjectType],
2223+
list[_ObjectType] | tuple[_ObjectType, ...],
22242224
]
22252225
),
22262226
context: _ContextType | None = None,
@@ -2962,19 +2962,19 @@ def triples_choices(
29622962
self,
29632963
triple: (
29642964
tuple[
2965-
list[_SubjectType] | tuple[_SubjectType],
2965+
list[_SubjectType] | tuple[_SubjectType, ...],
29662966
_PredicateType,
29672967
_ObjectType | None,
29682968
]
29692969
| tuple[
29702970
_SubjectType | None,
2971-
list[_PredicateType] | tuple[_PredicateType],
2971+
list[_PredicateType] | tuple[_PredicateType, ...],
29722972
_ObjectType | None,
29732973
]
29742974
| tuple[
29752975
_SubjectType | None,
29762976
_PredicateType,
2977-
list[_ObjectType] | tuple[_ObjectType],
2977+
list[_ObjectType] | tuple[_ObjectType, ...],
29782978
]
29792979
),
29802980
context: _ContextType | None = None,

rdflib/plugins/parsers/jsonld.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
# we should consider streaming the input to deal with arbitrarily large graphs.
3535
from __future__ import annotations
3636

37+
import secrets
3738
import warnings
3839
from collections.abc import Iterable
3940
from typing import TYPE_CHECKING, Any, Union
@@ -215,6 +216,7 @@ def __init__(
215216
if allow_lists_of_lists is not None
216217
else ALLOW_LISTS_OF_LISTS
217218
)
219+
self.invalid_uri_to_bnode: dict[str, BNode] = {}
218220

219221
def parse(self, data: Any, context: Context, dataset: Graph) -> Graph:
220222
topcontext = False
@@ -623,7 +625,12 @@ def _to_rdf_id(self, context: Context, id_val: str) -> IdentifiedNode | None:
623625
uri = context.resolve(id_val)
624626
if not self.generalized_rdf and ":" not in uri:
625627
return None
626-
return URIRef(uri)
628+
node: IdentifiedNode = URIRef(uri)
629+
if not str(node):
630+
if id_val not in self.invalid_uri_to_bnode:
631+
self.invalid_uri_to_bnode[id_val] = BNode(secrets.token_urlsafe(20))
632+
node = self.invalid_uri_to_bnode[id_val]
633+
return node
627634

628635
def _get_bnodeid(self, ref: str) -> str | None:
629636
if not ref.startswith("_:"):

0 commit comments

Comments
 (0)