|
@@ -224,11 +224,9 @@ class RuleOp:
|
224
|
224
|
op, items = pattern
|
225
|
225
|
except TypeError:
|
226
|
226
|
raise ValueError("pattern is not a tuple: %r" % pattern)
|
227
|
|
- try:
|
228
|
|
- assert issubclass(op, _BaseRuleOp)
|
229
|
|
- except TypeError:
|
|
227
|
+ if type(op) is not type:
|
230
|
228
|
raise ValueError("invalid operator: %r" % op)
|
231
|
|
- except AssertionError:
|
|
229
|
+ if not issubclass(op, _BaseRuleOp):
|
232
|
230
|
raise ValueError("invalid operator class: %s" % op.__name__)
|
233
|
231
|
return bool(op(items, item_ok))
|
234
|
232
|
|
|
@@ -272,9 +270,11 @@ class DictPath:
|
272
|
270
|
|
273
|
271
|
def _validate(self):
|
274
|
272
|
try:
|
275
|
|
- assert self._path.startswith(self.DIV)
|
276
|
|
- except (AttributeError, AssertionError):
|
277
|
|
- raise ValueError("invalid path: %r" % self._path)
|
|
273
|
+ has_root = self._path.startswith(self.DIV)
|
|
274
|
+ except AttributeError:
|
|
275
|
+ raise ValueError("invalid path: not a string: %r" % self._path)
|
|
276
|
+ if not has_root:
|
|
277
|
+ raise ValueError("invalid path: missing root: %r" % self._path)
|
278
|
278
|
|
279
|
279
|
def stripped(self):
|
280
|
280
|
return self._path.lstrip(self.DIV)
|