diff options
author | Matthias Baumgartner <dev@igsor.net> | 2023-01-12 10:22:59 +0100 |
---|---|---|
committer | Matthias Baumgartner <dev@igsor.net> | 2023-01-12 10:22:59 +0100 |
commit | 7e7284d5fc01c0a081aa79d67736f51069864a7d (patch) | |
tree | 94e900384bae4ea8e763d00a511023757ce88d40 /bsfs/triple_store/sparql | |
parent | 6b3e32b29799a8143e8ce9d20c5f27e3e166b9bb (diff) | |
download | bsfs-7e7284d5fc01c0a081aa79d67736f51069864a7d.tar.gz bsfs-7e7284d5fc01c0a081aa79d67736f51069864a7d.tar.bz2 bsfs-7e7284d5fc01c0a081aa79d67736f51069864a7d.zip |
adapt to non-optional range in query checks
Diffstat (limited to 'bsfs/triple_store/sparql')
-rw-r--r-- | bsfs/triple_store/sparql/parse_filter.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/bsfs/triple_store/sparql/parse_filter.py b/bsfs/triple_store/sparql/parse_filter.py index a851888..0297cbc 100644 --- a/bsfs/triple_store/sparql/parse_filter.py +++ b/bsfs/triple_store/sparql/parse_filter.py @@ -140,12 +140,10 @@ class Filter(): raise errors.ConsistencyError(f'ranges {subrng} and {rng} are not related') except TypeError as err: # subrng and rng are not comparable raise errors.ConsistencyError(f'ranges {subrng} and {rng} are not related') from err - if rng is None: - # for mypy to be certain of the rng type - # if rng were None, we'd have gotten a TypeError above (None > None) - raise errors.UnreachableError() # return joint predicate expression and next range - return '|'.join(suburi), rng + # OneOf guarantees at least one expression, rng is always a bsc.Vertex. + # mypy does not realize this, hence we ignore the warning. + return '|'.join(suburi), rng # type: ignore [return-value] def _predicate(self, node_type: bsc.Vertex, node: ast.filter.Predicate) -> typing.Tuple[str, bsc.Vertex]: """ @@ -159,9 +157,8 @@ class Filter(): if not self.schema.has_predicate(puri): raise errors.ConsistencyError(f'predicate {puri} is not in the schema') pred = self.schema.predicate(puri) - if pred.range is None: - # FIXME: It is a design error that Predicates can have a None range... - raise errors.BackendError(f'predicate {pred} has no range') + if not isinstance(pred.range, (bsc.Node, bsc.Literal)): + raise errors.BackendError(f'the range of predicate {pred} is undefined') dom, rng = pred.domain, pred.range # encapsulate predicate uri puri = f'<{puri}>' # type: ignore [assignment] # variable re-use confuses mypy |