Skip to content

Commit

Permalink
Don't use quoted forward annotations unless absolutely required, beca…
Browse files Browse the repository at this point in the history
…use 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+.
  • Loading branch information
ashleysommer authored Nov 7, 2024
1 parent 908afee commit a5ee441
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 50 deletions.
107 changes: 96 additions & 11 deletions poetry.lock

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

12 changes: 9 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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]
Expand Down
80 changes: 44 additions & 36 deletions rdflib/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,52 +309,60 @@
import rdflib.query
from rdflib.plugins.sparql.sparql import Query, Update

_SubjectType = Node
_PredicateType = Node
_ObjectType = Node
_ContextIdentifierType = IdentifiedNode

_TripleType = Tuple["_SubjectType", "_PredicateType", "_ObjectType"]
_QuadType = Tuple["_SubjectType", "_PredicateType", "_ObjectType", "_ContextType"]
_OptionalQuadType = Tuple[
"_SubjectType", "_PredicateType", "_ObjectType", Optional["_ContextType"]
_SubjectType: te.TypeAlias = Node
_PredicateType: te.TypeAlias = Node
_ObjectType: te.TypeAlias = Node
_ContextIdentifierType: te.TypeAlias = IdentifiedNode

_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 = Union["_TripleType", "_OptionalQuadType"]
_OptionalIdentifiedQuadType = Tuple[
"_SubjectType", "_PredicateType", "_ObjectType", Optional["_ContextIdentifierType"]
_TripleOrOptionalQuadType: te.TypeAlias = Union[_TripleType, _OptionalQuadType]
_OptionalIdentifiedQuadType: te.TypeAlias = Tuple[
_SubjectType, _PredicateType, _ObjectType, Optional[_ContextIdentifierType]
]
_TriplePatternType = Tuple[
Optional["_SubjectType"], Optional["_PredicateType"], Optional["_ObjectType"]
_TriplePatternType: te.TypeAlias = Tuple[
Optional[_SubjectType], Optional[_PredicateType], Optional[_ObjectType]
]
_TriplePathPatternType = Tuple[Optional["_SubjectType"], Path, Optional["_ObjectType"]]
_QuadPatternType = Tuple[
Optional["_SubjectType"],
Optional["_PredicateType"],
Optional["_ObjectType"],
_TriplePathPatternType: te.TypeAlias = Tuple[
Optional[_SubjectType], Path, 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
]
_TripleSelectorType: te.TypeAlias = Tuple[
Optional[_SubjectType],
Optional[Union[Path, _PredicateType]],
Optional[_ObjectType],
]
_QuadSelectorType = 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")
Expand Down Expand Up @@ -1896,7 +1904,7 @@ def add_to_cbd(uri: _SubjectType) -> None:
return subgraph


_ContextType = Graph
_ContextType: te.TypeAlias = Graph


class ConjunctiveGraph(Graph):
Expand Down

0 comments on commit a5ee441

Please sign in to comment.