Skip to content

Commit bb17072

Browse files
New sphinx docs fix (#2852)
* Fix typo, ConjunctionGraph -> ConjunctiveGraph, the new version of Sphinx-autodocs flagged this as an error. * more autodoc fixes for new sphinx version * Fix sphinx autodocs complaining while probing attributes on DefinedNamespace classes. Add correct annotation details for items that sphinx cannot find. --------- Co-authored-by: Nicholas Car <nick@kurrawong.net>
1 parent b35fd19 commit bb17072

File tree

5 files changed

+39
-18
lines changed

5 files changed

+39
-18
lines changed

poetry.lock

Lines changed: 6 additions & 6 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/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",
@@ -2227,8 +2234,9 @@ def parse(
22272234
22282235
See :meth:`rdflib.graph.Graph.parse` for documentation on arguments.
22292236
2230-
If the source is in a format that does not support named graphs it's triples
2231-
will be added to the default graph (i.e. `Dataset.default_context`).
2237+
If the source is in a format that does not support named graphs its triples
2238+
will be added to the default graph
2239+
(i.e. :attr:`ConjunctiveGraph.default_context`).
22322240
22332241
:Returns:
22342242
@@ -2254,7 +2262,7 @@ def parse(
22542262
the ``publicID`` parameter will also not be used as the name for the
22552263
graph that the data is loaded into, and instead the triples from sources
22562264
that do not support named graphs will be loaded into the default graph
2257-
(i.e. `ConjunctiveGraph.default_context`).
2265+
(i.e. :attr:`ConjunctiveGraph.default_context`).
22582266
"""
22592267

22602268
source = create_input_source(
@@ -2488,8 +2496,9 @@ def parse(
24882496
24892497
The source is specified using one of source, location, file or data.
24902498
2491-
If the source is in a format that does not support named graphs it's triples
2492-
will be added to the default graph (i.e. `Dataset.default_context`).
2499+
If the source is in a format that does not support named graphs its triples
2500+
will be added to the default graph
2501+
(i.e. :attr:`.Dataset.default_context`).
24932502
24942503
.. caution::
24952504
@@ -2510,7 +2519,7 @@ def parse(
25102519
the ``publicID`` parameter will also not be used as the name for the
25112520
graph that the data is loaded into, and instead the triples from sources
25122521
that do not support named graphs will be loaded into the default graph
2513-
(i.e. `ConjunctiveGraph.default_context`).
2522+
(i.e. :attr:`.Dataset.default_context`).
25142523
"""
25152524

25162525
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:

0 commit comments

Comments
 (0)