1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
From: Ashley Sommer <ashleysommer@gmail.com>
Date: Thu, 7 Nov 2024 10:09:03 +1000
Subject: Don't use quoted forward annotations unless absolutely required,
because autodocs-type-hints doesn't like it. (#2974)
Allow update to autodocs-type-hints 2.3.0, and Sphinx 7.4.x when running with Python 3.9+.
The patch is primarily for the debian packaging team to package RDFLib 7.1.2 with Sphinx 7.4 and autodocs-type-hints v2.3, on Python 3.9+.
---
pyproject.toml | 12 ++++++---
rdflib/graph.py | 78 +++++++++++++++++++++++++++++++--------------------------
2 files changed, 52 insertions(+), 38 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index fcdae02..6060e45 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -38,7 +38,7 @@ rdfs2dot = 'rdflib.tools.rdfs2dot:main'
rdfgraphisomorphism = 'rdflib.tools.graphisomorphism:main'
[tool.poetry.dependencies]
-python = "^3.8.1"
+python = ">=3.8.1"
isodate = {version=">=0.7.2,<1.0.0", python = "<3.11"}
pyparsing = ">=2.1.0,<4"
berkeleydb = {version = "^18.1.0", optional = true}
@@ -62,10 +62,16 @@ setuptools = ">=68,<72"
wheel = ">=0.42,<0.45"
[tool.poetry.group.docs.dependencies]
-sphinx = ">=7.1.2,<8"
+sphinx = [
+ {version = ">=7.1.2,<7.4", python = "<3.9"},
+ {version = ">=7.4.0,<8", python = ">=3.9"},
+]
myst-parser = ">=2,<4"
sphinxcontrib-apidoc = ">=0.3,<0.6"
-sphinx-autodoc-typehints = ">=1.25.3,<=2.0.1"
+sphinx-autodoc-typehints = [
+ {version = ">=1.25.3,<2.3", python = "<3.9"},
+ {version = ">=2.3.0,<2.4", python = ">=3.9"},
+]
typing-extensions = "^4.5.0"
[tool.poetry.group.lint.dependencies]
diff --git a/rdflib/graph.py b/rdflib/graph.py
index 80ccc3f..6c4c010 100644
--- a/rdflib/graph.py
+++ b/rdflib/graph.py
@@ -309,52 +309,60 @@ if TYPE_CHECKING:
import rdflib.query
from rdflib.plugins.sparql.sparql import Query, Update
-_SubjectType = Node
-_PredicateType = Node
-_ObjectType = Node
-_ContextIdentifierType = IdentifiedNode
+_SubjectType: te.TypeAlias = Node
+_PredicateType: te.TypeAlias = Node
+_ObjectType: te.TypeAlias = Node
+_ContextIdentifierType: te.TypeAlias = IdentifiedNode
-_TripleType = Tuple["_SubjectType", "_PredicateType", "_ObjectType"]
-_QuadType = Tuple["_SubjectType", "_PredicateType", "_ObjectType", "_ContextType"]
-_OptionalQuadType = Tuple[
- "_SubjectType", "_PredicateType", "_ObjectType", Optional["_ContextType"]
+_TripleType: te.TypeAlias = Tuple[_SubjectType, _PredicateType, _ObjectType]
+_TriplePathType: te.TypeAlias = Tuple[_SubjectType, Path, _ObjectType]
+_TripleOrTriplePathType: te.TypeAlias = Union[_TripleType, _TriplePathType]
+
+_QuadType: te.TypeAlias = Tuple[
+ _SubjectType, _PredicateType, _ObjectType, "_ContextType"
+]
+_OptionalQuadType: te.TypeAlias = Tuple[
+ _SubjectType, _PredicateType, _ObjectType, Optional["_ContextType"]
+]
+_TripleOrOptionalQuadType: te.TypeAlias = Union[_TripleType, _OptionalQuadType]
+_OptionalIdentifiedQuadType: te.TypeAlias = Tuple[
+ _SubjectType, _PredicateType, _ObjectType, Optional[_ContextIdentifierType]
]
-_TripleOrOptionalQuadType = Union["_TripleType", "_OptionalQuadType"]
-_OptionalIdentifiedQuadType = Tuple[
- "_SubjectType", "_PredicateType", "_ObjectType", Optional["_ContextIdentifierType"]
+_TriplePatternType: te.TypeAlias = Tuple[
+ Optional[_SubjectType], Optional[_PredicateType], Optional[_ObjectType]
]
-_TriplePatternType = Tuple[
- Optional["_SubjectType"], Optional["_PredicateType"], Optional["_ObjectType"]
+_TriplePathPatternType: te.TypeAlias = Tuple[
+ Optional[_SubjectType], Path, Optional[_ObjectType]
]
-_TriplePathPatternType = Tuple[Optional["_SubjectType"], Path, Optional["_ObjectType"]]
-_QuadPatternType = Tuple[
- Optional["_SubjectType"],
- Optional["_PredicateType"],
- Optional["_ObjectType"],
+_QuadPatternType: te.TypeAlias = Tuple[
+ Optional[_SubjectType],
+ Optional[_PredicateType],
+ Optional[_ObjectType],
Optional["_ContextType"],
]
-_QuadPathPatternType = Tuple[
- Optional["_SubjectType"],
+_QuadPathPatternType: te.TypeAlias = Tuple[
+ Optional[_SubjectType],
Path,
- Optional["_ObjectType"],
+ Optional[_ObjectType],
Optional["_ContextType"],
]
-_TripleOrQuadPatternType = Union["_TriplePatternType", "_QuadPatternType"]
-_TripleOrQuadPathPatternType = Union["_TriplePathPatternType", "_QuadPathPatternType"]
-_TripleSelectorType = Tuple[
- Optional["_SubjectType"],
- Optional[Union["Path", "_PredicateType"]],
- Optional["_ObjectType"],
+_TripleOrQuadPatternType: te.TypeAlias = Union[_TriplePatternType, _QuadPatternType]
+_TripleOrQuadPathPatternType: te.TypeAlias = Union[
+ _TriplePathPatternType, _QuadPathPatternType
]
-_QuadSelectorType = Tuple[
- Optional["_SubjectType"],
- Optional[Union["Path", "_PredicateType"]],
- Optional["_ObjectType"],
+_TripleSelectorType: te.TypeAlias = Tuple[
+ Optional[_SubjectType],
+ Optional[Union[Path, _PredicateType]],
+ Optional[_ObjectType],
+]
+_QuadSelectorType: te.TypeAlias = Tuple[
+ Optional[_SubjectType],
+ Optional[Union[Path, _PredicateType]],
+ Optional[_ObjectType],
Optional["_ContextType"],
]
-_TripleOrQuadSelectorType = Union["_TripleSelectorType", "_QuadSelectorType"]
-_TriplePathType = Tuple["_SubjectType", Path, "_ObjectType"]
-_TripleOrTriplePathType = Union["_TripleType", "_TriplePathType"]
+_TripleOrQuadSelectorType: te.TypeAlias = Union[_TripleSelectorType, _QuadSelectorType]
+
_GraphT = TypeVar("_GraphT", bound="Graph")
_ConjunctiveGraphT = TypeVar("_ConjunctiveGraphT", bound="ConjunctiveGraph")
@@ -1896,7 +1904,7 @@ class Graph(Node):
return subgraph
-_ContextType = Graph
+_ContextType: te.TypeAlias = Graph
class ConjunctiveGraph(Graph):
|