Skip to content

Commit 9688e4e

Browse files
authored
Merge branch 'main' into conjunctivegraph_serialize_trig1674
2 parents b10be47 + bb17072 commit 9688e4e

File tree

10 files changed

+81
-54
lines changed

10 files changed

+81
-54
lines changed

poetry.lock

Lines changed: 35 additions & 35 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
@@ -60,10 +60,10 @@ setuptools = ">=68,<72"
6060
wheel = ">=0.42,<0.44"
6161

6262
[tool.poetry.group.docs.dependencies]
63-
sphinx = "^7.1.1"
63+
sphinx = ">=7.1.2,<8"
6464
myst-parser = ">=2,<4"
6565
sphinxcontrib-apidoc = ">=0.3,<0.6"
66-
sphinx-autodoc-typehints = "^1.17.1"
66+
sphinx-autodoc-typehints = ">=1.25.3,<=2.0.1"
6767
typing-extensions = "^4.5.0"
6868

6969
[tool.poetry.group.lint.dependencies]

rdflib/extras/infixowl.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,10 @@ def subSumpteeIds(self): # noqa: N802
13291329
# predicate=RDFS.subClassOf,object=self.identifier):
13301330
# yield Class(s,skipOWLClassMembership=True)
13311331

1332-
def __repr__(self, full=False, normalization=True):
1332+
def __repr__(self):
1333+
return self.manchesterClass(full=False, normalization=True)
1334+
1335+
def manchesterClass(self, full=False, normalization=True): # noqa: N802
13331336
"""
13341337
Returns the Manchester Syntax equivalent for this class
13351338
"""

rdflib/graph.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,11 @@ class Graph(Node):
433433
For more on named graphs, see: http://www.w3.org/2004/03/trix/
434434
"""
435435

436+
context_aware: bool
437+
formula_aware: bool
438+
default_union: bool
439+
base: Optional[str]
440+
436441
def __init__(
437442
self,
438443
store: Union[Store, str] = "default",
@@ -1393,9 +1398,9 @@ def parse(
13931398
:doc:`Security Considerations </security_considerations>`
13941399
documentation.
13951400
1396-
:param source: An `InputSource`, file-like object, `Path` like object,
1397-
or string. In the case of a string the string is the location of the
1398-
source.
1401+
:param source: An `xml.sax.xmlreader.InputSource`, file-like object,
1402+
`pathlib.Path` like object, or string. In the case of a string the string
1403+
is the location of the source.
13991404
:param location: A string indicating the relative or absolute URL of the
14001405
source. `Graph`'s absolutize method is used if a relative location
14011406
is specified.
@@ -1910,6 +1915,8 @@ class ConjunctiveGraph(Graph):
19101915
All queries are carried out against the union of all graphs.
19111916
"""
19121917

1918+
default_context: _ContextType
1919+
19131920
def __init__(
19141921
self,
19151922
store: Union[Store, str] = "default",
@@ -2298,8 +2305,9 @@ def parse(
22982305
22992306
See :meth:`rdflib.graph.Graph.parse` for documentation on arguments.
23002307
2301-
If the source is in a format that does not support named graphs it's triples
2302-
will be added to the default graph (i.e. `Dataset.default_context`).
2308+
If the source is in a format that does not support named graphs its triples
2309+
will be added to the default graph
2310+
(i.e. :attr:`ConjunctiveGraph.default_context`).
23032311
23042312
:Returns:
23052313
@@ -2325,7 +2333,7 @@ def parse(
23252333
the ``publicID`` parameter will also not be used as the name for the
23262334
graph that the data is loaded into, and instead the triples from sources
23272335
that do not support named graphs will be loaded into the default graph
2328-
(i.e. `ConjunctionGraph.default_context`).
2336+
(i.e. :attr:`ConjunctiveGraph.default_context`).
23292337
"""
23302338

23312339
source = create_input_source(
@@ -2559,8 +2567,9 @@ def parse(
25592567
25602568
The source is specified using one of source, location, file or data.
25612569
2562-
If the source is in a format that does not support named graphs it's triples
2563-
will be added to the default graph (i.e. `Dataset.default_context`).
2570+
If the source is in a format that does not support named graphs its triples
2571+
will be added to the default graph
2572+
(i.e. :attr:`.Dataset.default_context`).
25642573
25652574
.. caution::
25662575
@@ -2581,7 +2590,7 @@ def parse(
25812590
the ``publicID`` parameter will also not be used as the name for the
25822591
graph that the data is loaded into, and instead the triples from sources
25832592
that do not support named graphs will be loaded into the default graph
2584-
(i.e. `ConjunctionGraph.default_context`).
2593+
(i.e. :attr:`.Dataset.default_context`).
25852594
"""
25862595

25872596
c = ConjunctiveGraph.parse(

rdflib/namespace/_WGS.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class WGS(DefinedNamespace):
77
Basic Geo (WGS84 lat/long) Vocabulary
88
99
The HTML Specification for the vocabulary can be found
10-
`here <https://www.w3.org/2003/01/geo/>`.
10+
here <https://www.w3.org/2003/01/geo/>.
1111
"""
1212

1313
_NS = Namespace("https://www.w3.org/2003/01/geo/wgs84_pos#")

rdflib/namespace/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ def __repr__(self) -> str:
233233
"_underscore_num",
234234
}
235235

236+
# Some libraries probe classes for certain attributes or items.
237+
# This is a list of those attributes and items that should be ignored.
238+
_IGNORED_ATTR_LOOKUP: Set[str] = {
239+
"_pytestfixturefunction", # pytest tries to look this up on Defined namespaces
240+
"_partialmethod", # sphinx tries to look this up during autodoc generation
241+
}
242+
236243

237244
class DefinedNamespaceMeta(type):
238245
"""Utility metaclass for generating URIRefs with a common prefix."""
@@ -246,10 +253,13 @@ class DefinedNamespaceMeta(type):
246253
@lru_cache(maxsize=None)
247254
def __getitem__(cls, name: str, default=None) -> URIRef:
248255
name = str(name)
256+
249257
if name in _DFNS_RESERVED_ATTRS:
250258
raise AttributeError(
251259
f"DefinedNamespace like object has no attribute {name!r}"
252260
)
261+
elif name in _IGNORED_ATTR_LOOKUP:
262+
raise KeyError()
253263
if str(name).startswith("__"):
254264
# NOTE on type ignore: This seems to be a real bug, super() does not
255265
# implement this method, it will fail if it is ever reached.
@@ -265,6 +275,8 @@ def __getitem__(cls, name: str, default=None) -> URIRef:
265275
return cls._NS[name]
266276

267277
def __getattr__(cls, name: str):
278+
if name in _IGNORED_ATTR_LOOKUP:
279+
raise AttributeError()
268280
return cls.__getitem__(name)
269281

270282
def __repr__(cls) -> str:

test/test_extras/test_infixowl/test_class.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def test_class_getparents(graph):
153153

154154
assert list(sibling.subSumpteeIds()) == []
155155

156-
assert str(brother.__repr__(full=True)) == "Class: ex:Brother "
156+
assert str(brother.manchesterClass(full=True)) == "Class: ex:Brother "
157157

158158
assert graph.serialize(format="ttl") == (
159159
"@prefix ex: <http://example.org/vocab/> .\n"
@@ -251,7 +251,7 @@ def test_class_serialize(graph):
251251

252252
assert str(owlc.__invert__()) == "Some Class DisjointWith ( NOT ex:Sister )\n"
253253

254-
assert owlc.__repr__(full=True) == (
254+
assert owlc.manchesterClass(full=True) == (
255255
"Class: ex:test \n"
256256
" ## A Defined Class (Man) ##\n"
257257
" This is a Man\n"

test/test_serializers/test_serializer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,4 +717,5 @@ def test_serialize_to_fileuri_with_authortiy(
717717
format=format.info.serializer,
718718
)
719719
assert False # this should never happen as serialize should always fail
720-
assert catcher.value is not None
720+
# type error, mypy thinks this line is unreachable, but it works fine
721+
assert catcher.value is not None # type: ignore[unreachable, unused-ignore]

test/test_sparql/test_result.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,4 +441,5 @@ def test_serialize_to_fileuri_with_authortiy(
441441
encoding=encoding,
442442
)
443443
assert False # this should never happen as serialize should always fail
444-
assert catcher.value is not None
444+
# type error, mypy thinks this line is unreachable, but it works fine
445+
assert catcher.value is not None # type: ignore[unreachable, unused-ignore]

test/utils/test/test_outcome.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from contextlib import ExitStack
4-
from typing import Any, Callable, NoReturn, Optional, Type, Union
4+
from typing import Any, Callable, NoReturn, Optional, Type, Union, cast
55

66
import pytest
77

@@ -16,7 +16,8 @@ def _raise(
1616
if isinstance(what, type) and issubclass(what, Exception):
1717
raise what(*args, **kwargs)
1818
elif callable(what):
19-
raise what(*args, **kwargs)
19+
what_fn: Callable[..., Exception] = cast(Callable[..., Exception], what)
20+
raise what_fn(*args, **kwargs)
2021

2122

2223
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)