Skip to content

Commit 40e3b9d

Browse files
committed
checkpoint
1 parent ed2e008 commit 40e3b9d

File tree

7 files changed

+14
-66
lines changed

7 files changed

+14
-66
lines changed

rdflib/plugins/sparql/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
"""
42
SPARQL implementation for RDFLib
53

rdflib/plugins/sparql/aggregates.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,7 @@ def type_safe_numbers(*args: Union[Decimal, float, int]) -> Iterable[Union[float
106106
if any(isinstance(arg, float) for arg in args) and any(
107107
isinstance(arg, Decimal) for arg in args
108108
):
109-
# pytype error: bad return type
110-
# Expected: Tuple[Union[float, int]]
111-
# Actually returned: Iterator[float]
112-
return map(float, args) # pytype: disable=bad-return-type
109+
return map(float, args)
113110
# type error: Incompatible return value type (got "Tuple[Union[Decimal, float, int], ...]", expected "Iterable[Union[float, int]]")
114111
# NOTE on type error: if args contains a Decimal it will nopt get here.
115112
return args # type: ignore[return-value]
@@ -139,10 +136,7 @@ def update(self, row: FrozenBindings, aggregator: "Aggregator") -> None:
139136
pass
140137

141138
def get_value(self) -> Literal:
142-
# pytype error: Invalid keyword argument datatype to function Literal.__init__
143-
return Literal(
144-
self.value, datatype=self.datatype
145-
) # pytype: disable=wrong-keyword-args
139+
return Literal(self.value, datatype=self.datatype)
146140

147141

148142
class Average(Accumulator):
@@ -203,18 +197,14 @@ def update(self, row: FrozenBindings, aggregator: "Aggregator") -> None:
203197
self.value = _eval(self.expr, row)
204198
else:
205199
# self.compare is implemented by Minimum/Maximum
206-
# pytype error: No attribute 'compare' on Extremum
207-
self.value = self.compare(
208-
self.value, _eval(self.expr, row)
209-
) # pytype: disable=attribute-error
200+
self.value = self.compare(self.value, _eval(self.expr, row))
210201
# skip UNDEF or BNode => SPARQLTypeError
211202
except NotBoundError:
212203
pass
213204
except SPARQLTypeError:
214205
pass
215206

216207

217-
# _ValueT = TypeVar("_ValueT", bound=Union[Variable, BNode, URIRef, Literal])
218208
_ValueT = TypeVar("_ValueT", Variable, BNode, URIRef, Literal)
219209

220210

@@ -307,8 +297,7 @@ def update(self, row: FrozenBindings) -> None:
307297

308298
for acc in list(self.accumulators.values()):
309299
if acc.use_row(row):
310-
# pytype error: No attribute 'update' on Accumulator
311-
acc.update(row, self) # pytype: disable=attribute-error
300+
acc.update(row, self)
312301

313302
def get_bindings(self) -> Mapping[Variable, Identifier]:
314303
"""calculate and set last values"""

rdflib/plugins/sparql/evaluate.py

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

3-
from ...paths import Path
4-
53
"""
64
These method recursively evaluate the SPARQL Algebra
75
@@ -62,6 +60,9 @@
6260
)
6361
from rdflib.term import BNode, Identifier, Literal, URIRef, Variable
6462

63+
if TYPE_CHECKING:
64+
from rdflib.paths import Path
65+
6566
_Triple = Tuple[Identifier, Identifier, Identifier]
6667

6768

rdflib/plugins/sparql/evalutils.py

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828
if TYPE_CHECKING:
2929
from .sparql import _ContextType
3030

31-
FrozenDictT = TypeVar("FrozenDictT", bound=FrozenDict)
31+
_FrozenDictT = TypeVar("_FrozenDictT", bound=FrozenDict)
3232

3333

34-
def _diff(a: Iterable[FrozenDictT], b: Iterable[FrozenDictT], expr) -> Set[FrozenDictT]:
34+
def _diff(
35+
a: Iterable[_FrozenDictT], b: Iterable[_FrozenDictT], expr
36+
) -> Set[_FrozenDictT]:
3537
res = set()
3638

3739
for x in a:
@@ -42,8 +44,8 @@ def _diff(a: Iterable[FrozenDictT], b: Iterable[FrozenDictT], expr) -> Set[Froze
4244

4345

4446
def _minus(
45-
a: Iterable[FrozenDictT], b: Iterable[FrozenDictT]
46-
) -> Generator[FrozenDictT, None, None]:
47+
a: Iterable[_FrozenDictT], b: Iterable[_FrozenDictT]
48+
) -> Generator[_FrozenDictT, None, None]:
4749
for x in a:
4850
if all((not x.compatible(y)) or x.disjointDomain(y) for y in b):
4951
yield x
@@ -177,31 +179,9 @@ def _fillTemplate(
177179
yield (_s, _p, _o)
178180

179181

180-
# @overload
181-
# def _val(v: Variable) -> Tuple[int, Variable]:
182-
# ...
183-
184-
185-
# @overload
186-
# def _val(v: BNode) -> Tuple[int, BNode]:
187-
# ...
188-
189-
190-
# @overload
191-
# def _val(v: URIRef) -> Tuple[int, URIRef]:
192-
# ...
193-
194-
195-
# @overload
196-
# def _val(v: Literal) -> Tuple[int, Literal]:
197-
# ...
198-
199182
_ValueT = TypeVar("_ValueT", Variable, BNode, URIRef, Literal)
200183

201184

202-
# def _val(
203-
# v: Union[Variable, BNode, URIRef, Literal]
204-
# ) -> Tuple[int, Union[Variable, BNode, URIRef, Literal]]:
205185
def _val(v: _ValueT) -> Tuple[int, _ValueT]:
206186
"""utilitity for ordering things"""
207187
if isinstance(v, Variable):

rdflib/plugins/sparql/sparql.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -462,18 +462,3 @@ def __init__(self, prologue: Prologue, algebra: List[CompValue]):
462462
self.prologue = prologue
463463
self.algebra = algebra
464464
self._original_args: Tuple[str, Mapping[str, str], Optional[str]]
465-
466-
467-
__all__ = [
468-
"SPARQLError",
469-
"NotBoundError",
470-
"AlreadyBound",
471-
"SPARQLTypeError",
472-
"Bindings",
473-
"FrozenDict",
474-
"FrozenBindings",
475-
"QueryContext",
476-
"Prologue",
477-
"Query",
478-
"Update",
479-
]

rdflib/term.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
"""
42
This module defines the different types of terms. Terms are the kinds of
53
objects that can appear in a quoted/asserted triple. This includes those

rdflib/void.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
from __future__ import annotations
2-
31
import collections
42

5-
from rdflib.graph import Graph
3+
from rdflib import Graph, Literal, URIRef
64
from rdflib.namespace import RDF, VOID
7-
from rdflib.term import Literal, URIRef
85

96

107
def generateVoID( # noqa: N802

0 commit comments

Comments
 (0)