hmr 0.6.0__py3-none-any.whl → 0.6.0.2__py3-none-any.whl

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.1
2
2
  Name: hmr
3
- Version: 0.6.0
3
+ Version: 0.6.0.2
4
4
  Summary: Hot Module Reload for Python
5
5
  Project-URL: repository, https://github.com/promplate/pyth-on-line/tree/reactivity
6
6
  Requires-Python: >=3.12
@@ -0,0 +1,15 @@
1
+ hmr-0.6.0.2.dist-info/METADATA,sha256=4LUh5-zVBQrBIIJZEADU0kQSs-cds3lRP2D8UE-RmO4,2001
2
+ hmr-0.6.0.2.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
+ hmr-0.6.0.2.dist-info/entry_points.txt,sha256=g_T0uJ43WgsdG14kkkdaBQuIL0HO-m1qvtjXMP6d060,59
4
+ reactivity/__init__.py,sha256=pX-RUzkezCC1x4eOWGxNhXbwrbvBLP_3pQuZr9eZz1Y,300
5
+ reactivity/context.py,sha256=hgf3U4ihtGSVZ8mGvXcjKcO1U5i7lwX-LadDraAjdNg,1402
6
+ reactivity/functional.py,sha256=jJLEq88w5ag2cXuD1T118uEjnEg37_mqvWmFkb47KVY,1300
7
+ reactivity/helpers.py,sha256=ZhpsIYoUyUSWaAsvCP7BlYxGhxySxHaU1WdRtHOn95k,5882
8
+ reactivity/hmr/__init__.py,sha256=S5ZIHqCRpevdzWuhS0aCua_S8F0LkK0YNg6IgeTScFQ,177
9
+ reactivity/hmr/__main__.py,sha256=uIcyjR5gMFIXH_3hS0B3SD00RirVf7GIct-uItx675o,64
10
+ reactivity/hmr/api.py,sha256=ypS_LyzMH1JbN5cSwamAJ0HEcHMOY7BOIINuJmWJwo8,2283
11
+ reactivity/hmr/core.py,sha256=Ms87q0QmQuRpj_6Abq9gDh3eKYVCxXJZesnZLQjuHQI,11837
12
+ reactivity/hmr/hooks.py,sha256=jIFpe4CNxfaS9RcR4OIodx_sOZlnJ_IA1T1RtHPXhwU,945
13
+ reactivity/hmr/utils.py,sha256=h9m7iRXlvsLTrHoXV9gEVbhz3XsPK4KgnStYoCAWE5I,1616
14
+ reactivity/primitives.py,sha256=_I6mG1qPBH6Vsktlf3-0mXpRO6L1hFhbfRtNMrpVxS8,6906
15
+ hmr-0.6.0.2.dist-info/RECORD,,
reactivity/context.py CHANGED
@@ -6,7 +6,7 @@ from functools import partial
6
6
  from typing import TYPE_CHECKING, NamedTuple
7
7
 
8
8
  if TYPE_CHECKING:
9
- from .primitives import BaseComputation, Batch
9
+ from .primitives import BaseComputation
10
10
 
11
11
 
12
12
  class Context(NamedTuple):
@@ -28,25 +28,30 @@ class Context(NamedTuple):
28
28
 
29
29
  @property
30
30
  def batch(self):
31
- from .primitives import Batch
32
-
33
31
  return partial(Batch, context=self)
34
32
 
35
33
  @property
36
34
  def signal(self):
37
- from .primitives import Signal
38
-
39
35
  return partial(Signal, context=self)
40
36
 
41
37
  @property
42
38
  def effect(self):
43
- from .primitives import Effect
44
-
45
39
  return partial(Effect, context=self)
46
40
 
41
+ @contextmanager
42
+ def untrack(self):
43
+ computations = self.current_computations[:]
44
+ self.current_computations.clear()
45
+ try:
46
+ yield
47
+ finally:
48
+ self.current_computations[:] = computations
49
+
47
50
 
48
51
  def new_context():
49
52
  return Context([], [])
50
53
 
51
54
 
52
55
  default_context = new_context()
56
+
57
+ from .primitives import Batch, Effect, Signal
reactivity/helpers.py CHANGED
@@ -127,7 +127,8 @@ class Reactive[K, V](Subscribable, MutableMapping[K, V]):
127
127
 
128
128
  def items(self):
129
129
  self.track()
130
- return ({k: v.get() for k, v in self._signals.items()}).items()
130
+ unset = self.UNSET
131
+ return ({k: v for k, signal in self._signals.items() if (v := signal.get()) is not unset}).items()
131
132
 
132
133
 
133
134
  class DerivedProperty[T, I]:
reactivity/hmr/core.py CHANGED
@@ -344,4 +344,4 @@ def cli():
344
344
  reloader.keep_watching_until_interrupt()
345
345
 
346
346
 
347
- __version__ = "0.6.0"
347
+ __version__ = "0.6.0.2"
reactivity/primitives.py CHANGED
@@ -34,8 +34,9 @@ class Subscribable:
34
34
  return
35
35
  last = self.context.current_computations[-1]
36
36
  if last is not self:
37
- self.subscribers.add(last)
38
- last.dependencies.add(self)
37
+ with self.context.untrack():
38
+ self.subscribers.add(last)
39
+ last.dependencies.add(self)
39
40
 
40
41
  def notify(self):
41
42
  if self.context.batches:
@@ -1,15 +0,0 @@
1
- hmr-0.6.0.dist-info/METADATA,sha256=AQEgb94qk_NRTRAap3w-eie4GVIebx3ZPzUPWrrN_98,1999
2
- hmr-0.6.0.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
- hmr-0.6.0.dist-info/entry_points.txt,sha256=g_T0uJ43WgsdG14kkkdaBQuIL0HO-m1qvtjXMP6d060,59
4
- reactivity/__init__.py,sha256=pX-RUzkezCC1x4eOWGxNhXbwrbvBLP_3pQuZr9eZz1Y,300
5
- reactivity/context.py,sha256=Iuq1uXYJjQeizOucocu56ObGy5O_sb7Q-mXeKJzAwMA,1239
6
- reactivity/functional.py,sha256=jJLEq88w5ag2cXuD1T118uEjnEg37_mqvWmFkb47KVY,1300
7
- reactivity/helpers.py,sha256=MoIU6UmvPDC31HW5mQn2kFKJZNjrzioLXXEyYQMHUuw,5820
8
- reactivity/hmr/__init__.py,sha256=S5ZIHqCRpevdzWuhS0aCua_S8F0LkK0YNg6IgeTScFQ,177
9
- reactivity/hmr/__main__.py,sha256=uIcyjR5gMFIXH_3hS0B3SD00RirVf7GIct-uItx675o,64
10
- reactivity/hmr/api.py,sha256=ypS_LyzMH1JbN5cSwamAJ0HEcHMOY7BOIINuJmWJwo8,2283
11
- reactivity/hmr/core.py,sha256=OMgjdnvv6QWUmDmJxInuT93RwWuwNSicHTdgF0k4vL4,11835
12
- reactivity/hmr/hooks.py,sha256=jIFpe4CNxfaS9RcR4OIodx_sOZlnJ_IA1T1RtHPXhwU,945
13
- reactivity/hmr/utils.py,sha256=h9m7iRXlvsLTrHoXV9gEVbhz3XsPK4KgnStYoCAWE5I,1616
14
- reactivity/primitives.py,sha256=z69PqQxizN2sbursmpKW5SlWshlZZzdLgFH9u8E5eZc,6857
15
- hmr-0.6.0.dist-info/RECORD,,
File without changes