python-library-reactive-model 0.1.0__tar.gz → 0.1.1__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,4 +1,4 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-library-reactive-model
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Requires-Python: >=3.10
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "python-library-reactive-model"
7
- version = "0.1.0"
7
+ version = "0.1.1"
8
8
  requires-python = ">=3.10"
9
9
  dependencies = []
10
10
 
@@ -10,7 +10,11 @@ _MISSING = object()
10
10
 
11
11
 
12
12
  class ComputedModel(ReactiveModel[T]):
13
- def __init__(self, expr: Callable[[], T]) -> None:
13
+ def __init__(self, expr: Callable[[], T]=None) -> None:
14
+ """
15
+ Args:
16
+ expr: The expression to compute the value.
17
+ """
14
18
  super().__init__()
15
19
  self._expr = expr
16
20
  self._cache: T | object = _MISSING
@@ -40,6 +44,9 @@ class ComputedModel(ReactiveModel[T]):
40
44
  return False
41
45
 
42
46
  def _recompute(self) -> None:
47
+ if self._expr is None:
48
+ raise ValueError("require expr to compute")
49
+
43
50
  collector = Collector()
44
51
 
45
52
  with compute_context(self, collector):