aboutsummaryrefslogtreecommitdiffstats
path: root/bsfs
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2023-02-08 21:08:24 +0100
committerMatthias Baumgartner <dev@igsor.net>2023-02-08 21:08:24 +0100
commitf31a0d005785d474a37ec769c1f7f5e27aa08a57 (patch)
tree784c0ca9311dc43017418ff59ea88a2ea9815f8c /bsfs
parent64f3ac76a2f8d6b51380c06233accfcc19dca228 (diff)
downloadbsfs-f31a0d005785d474a37ec769c1f7f5e27aa08a57.tar.gz
bsfs-f31a0d005785d474a37ec769c1f7f5e27aa08a57.tar.bz2
bsfs-f31a0d005785d474a37ec769c1f7f5e27aa08a57.zip
minor comments
Diffstat (limited to 'bsfs')
-rw-r--r--bsfs/graph/nodes.py2
-rw-r--r--bsfs/graph/resolve.py1
-rw-r--r--bsfs/graph/result.py2
-rw-r--r--bsfs/graph/walk.py4
-rw-r--r--bsfs/query/ast/filter_.py17
-rw-r--r--bsfs/query/validator.py1
6 files changed, 17 insertions, 10 deletions
diff --git a/bsfs/graph/nodes.py b/bsfs/graph/nodes.py
index 9990714..bc71a32 100644
--- a/bsfs/graph/nodes.py
+++ b/bsfs/graph/nodes.py
@@ -199,6 +199,7 @@ class Nodes():
"""Get values or nodes at *paths*.
Return an iterator (view=list) or a dict (view=dict) over the results.
"""
+ # FIXME: user-provided Fetch query AST?
# check args
if len(paths) == 0:
raise AttributeError('expected at least one path, found none')
@@ -345,6 +346,7 @@ class Nodes():
elif isinstance(pred.range, bsc.Node):
# check value type
+ # FIXME: value could be a set of Nodes
if not isinstance(value, Nodes):
raise TypeError(value)
# value's node_type must be a subclass of the predicate's range
diff --git a/bsfs/graph/resolve.py b/bsfs/graph/resolve.py
index 00b778b..4677401 100644
--- a/bsfs/graph/resolve.py
+++ b/bsfs/graph/resolve.py
@@ -41,6 +41,7 @@ class Filter():
self.schema = schema
def __call__(self, root_type: bsc.Node, node: ast.filter.FilterExpression):
+ # FIXME: node can be None!
return self._parse_filter_expression(root_type, node)
def _parse_filter_expression(
diff --git a/bsfs/graph/result.py b/bsfs/graph/result.py
index 00607f4..31822f1 100644
--- a/bsfs/graph/result.py
+++ b/bsfs/graph/result.py
@@ -109,10 +109,12 @@ def to_dict_view(
# FIXME: Combine multiple Nodes instances into one?
# convert defaultdict to ordinary dict
+ # pylint: disable=too-many-boolean-expressions
if not node and not path and not value \
and len(unique_paths) > 0 and one_node and one_path \
and len(data) == 0:
return default
+ # pylint: enable=too-many-boolean-expressions
if not node and not path:
return data
if node ^ path:
diff --git a/bsfs/graph/walk.py b/bsfs/graph/walk.py
index 63ef5e9..1b1cfa0 100644
--- a/bsfs/graph/walk.py
+++ b/bsfs/graph/walk.py
@@ -88,9 +88,9 @@ class Walk(abc.Hashable, abc.Callable): # type: ignore [misc] # invalid base cla
if pred.uri.get('fragment', None) == name
)
if len(predicates) == 0: # no fragment found for name
- raise ValueError(f'no available predicate matches {name}')
+ raise ValueError(f'no available predicate matches {name}') # FIXME: Custom exception
if len(predicates) > 1: # ambiguous name
- raise ValueError(f'{name} matches multiple predicates')
+ raise ValueError(f'{name} matches multiple predicates') # FIXME: Custom exception
# append predicate to walk
return predicates # type: ignore [return-value] # size is one
diff --git a/bsfs/query/ast/filter_.py b/bsfs/query/ast/filter_.py
index 44490fc..b29d89e 100644
--- a/bsfs/query/ast/filter_.py
+++ b/bsfs/query/ast/filter_.py
@@ -31,7 +31,7 @@ from collections import abc
import typing
# bsfs imports
-from bsfs.utils import URI, errors, typename, normalize_args
+from bsfs.utils import URI, typename, normalize_args
# exports
__all__ : typing.Sequence[str] = (
@@ -454,8 +454,9 @@ class OneOf(PredicateExpression, abc.Collection):
# Helpers
+# invalid-name is disabled since they explicitly mimic an expression
-def IsIn(*values): # pylint: disable=invalid-name # explicitly mimics an expression
+def IsIn(*values) -> FilterExpression: # pylint: disable=invalid-name
"""Match any of the given URIs."""
args = normalize_args(*values)
if len(args) == 0:
@@ -464,17 +465,17 @@ def IsIn(*values): # pylint: disable=invalid-name # explicitly mimics an express
return Is(args[0])
return Or(Is(value) for value in args)
-def IsNotIn(*values): # pylint: disable=invalid-name # explicitly mimics an expression
+def IsNotIn(*values) -> FilterExpression: # pylint: disable=invalid-name
"""Match none of the given URIs."""
return Not(IsIn(*values))
-def Between(
+def Between( # pylint: disable=invalid-name
lo: float = float('-inf'),
hi: float = float('inf'),
lo_strict: bool = True,
hi_strict: bool = True,
- ):
+ ) -> FilterExpression :
"""Match numerical values between *lo* and *hi*. Include bounds if strict is False."""
if abs(lo) == hi == float('inf'):
raise ValueError('range cannot be INF on both sides')
@@ -483,7 +484,7 @@ def Between(
if lo == hi and not lo_strict and not hi_strict:
return Equals(lo)
if lo == hi: # either bound is strict
- raise ValueError(f'bounds cannot be equal when either is strict')
+ raise ValueError('bounds cannot be equal when either is strict')
if lo != float('-inf') and hi != float('inf'):
return And(GreaterThan(lo, lo_strict), LessThan(hi, hi_strict))
if lo != float('-inf'):
@@ -492,7 +493,7 @@ def Between(
return LessThan(hi, hi_strict)
-def Includes(*values, approx: bool = False):
+def Includes(*values, approx: bool = False) -> FilterExpression: # pylint: disable=invalid-name
"""Match any of the given *values*. Uses `Substring` if *approx* is set."""
args = normalize_args(*values)
cls = Substring if approx else Equals
@@ -503,7 +504,7 @@ def Includes(*values, approx: bool = False):
return Or(cls(v) for v in args)
-def Excludes(*values, approx: bool = False):
+def Excludes(*values, approx: bool = False) -> FilterExpression: # pylint: disable=invalid-name
"""Match none of the given *values*. Uses `Substring` if *approx* is set."""
args = normalize_args(*values)
cls = Substring if approx else Equals
diff --git a/bsfs/query/validator.py b/bsfs/query/validator.py
index 9fbff12..f0aa795 100644
--- a/bsfs/query/validator.py
+++ b/bsfs/query/validator.py
@@ -20,6 +20,7 @@ __all__ : typing.Sequence[str] = (
'Filter',
)
+# FIXME: Split into a submodule and the two classes into their own respective files.
## code ##