pyspecification 2.0.1__tar.gz → 2.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pyspecification
3
- Version: 2.0.1
3
+ Version: 2.0.2
4
4
  Summary: A lightweight, typed Python library for composing business rules as reusable, executable predicates.
5
5
  Author: aaltatan
6
6
  Author-email: aaltatan <a.altatan@gmail.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pyspecification"
3
- version = "2.0.1"
3
+ version = "2.0.2"
4
4
  description = "A lightweight, typed Python library for composing business rules as reusable, executable predicates."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pyspecification"
3
- version = "2.0.1"
3
+ version = "2.0.2"
4
4
  description = "A lightweight, typed Python library for composing business rules as reusable, executable predicates."
5
5
  readme = "README.md"
6
6
  authors = [{ name = "aaltatan", email = "a.altatan@gmail.com" }]
@@ -172,12 +172,12 @@ class ObjectRulesRegistry[T, R: ReturnType]:
172
172
  ) -> ObjectRuleFn[T, R, P]:
173
173
  rule_name = _process_rule_name(fn, name)
174
174
 
175
- if hidden:
176
- self._hidden.add(rule_name)
177
-
178
175
  if rule_name in self._rules:
179
176
  raise RuleAlreadyRegisteredError(rule_name)
180
177
 
178
+ if hidden:
179
+ self._hidden.add(rule_name)
180
+
181
181
  @wraps(fn)
182
182
  def wrapper(*args: P.args, **kwargs: P.kwargs) -> Predicate[T, R]:
183
183
  processed_args, processed_kwargs = process_arguments(processors, *args, **kwargs)
@@ -364,12 +364,12 @@ class SubscriptableRulesRegistry[T, K, R: ReturnType]:
364
364
  ) -> SubscriptableRuleFn[T, K, R, P]:
365
365
  rule_name = _process_rule_name(fn, name)
366
366
 
367
- if hidden:
368
- self._hidden.add(rule_name)
369
-
370
367
  if rule_name in self._rules:
371
368
  raise RuleAlreadyRegisteredError(rule_name)
372
369
 
370
+ if hidden:
371
+ self._hidden.add(rule_name)
372
+
373
373
  @wraps(fn)
374
374
  def wrapper(key: K, *args: P.args, **kwargs: P.kwargs) -> Predicate[T, R]:
375
375
 
@@ -168,7 +168,7 @@ def subscriptable_rule[T, K, R: ReturnType, **P](
168
168
  check_key_existence
169
169
  and isinstance(obj, list)
170
170
  and isinstance(key, int)
171
- and len(obj) <= key
171
+ and not (-len(obj) <= key < len(obj))
172
172
  ),
173
173
  lambda: check_key_existence and isinstance(obj, dict) and key not in obj,
174
174
  ]