hmr 0.4.3__py3-none-any.whl → 0.5.1__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.4.3
3
+ Version: 0.5.1
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,14 @@
1
+ hmr-0.5.1.dist-info/METADATA,sha256=ad1Eq5-t1QdaHg5SI1N_CIvz_ADraD8FCvPtj5Xvek8,258
2
+ hmr-0.5.1.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
+ hmr-0.5.1.dist-info/entry_points.txt,sha256=g_T0uJ43WgsdG14kkkdaBQuIL0HO-m1qvtjXMP6d060,59
4
+ reactivity/__init__.py,sha256=pX-RUzkezCC1x4eOWGxNhXbwrbvBLP_3pQuZr9eZz1Y,300
5
+ reactivity/functional.py,sha256=jJLEq88w5ag2cXuD1T118uEjnEg37_mqvWmFkb47KVY,1300
6
+ reactivity/helpers.py,sha256=rcrCXy1mmlei-if_BN4nSgS2IG9kBj-jq1YRwEfcITo,5329
7
+ reactivity/hmr/__init__.py,sha256=S5ZIHqCRpevdzWuhS0aCua_S8F0LkK0YNg6IgeTScFQ,177
8
+ reactivity/hmr/__main__.py,sha256=uIcyjR5gMFIXH_3hS0B3SD00RirVf7GIct-uItx675o,64
9
+ reactivity/hmr/api.py,sha256=Esb1fYiBW0SLxQ0MPXby25ZgIIZhIp-M3b2KiqpffmU,2094
10
+ reactivity/hmr/core.py,sha256=BHtkX5b3MAu-dxiMMuAn-8F6JnTkKZSNbEew7Wk59bc,11571
11
+ reactivity/hmr/hooks.py,sha256=jIFpe4CNxfaS9RcR4OIodx_sOZlnJ_IA1T1RtHPXhwU,945
12
+ reactivity/hmr/utils.py,sha256=h9m7iRXlvsLTrHoXV9gEVbhz3XsPK4KgnStYoCAWE5I,1616
13
+ reactivity/primitives.py,sha256=QkiUF8bqLZtyXguWwNJi34HJIc-SzUKqi1M9UgTNuvI,5952
14
+ hmr-0.5.1.dist-info/RECORD,,
reactivity/functional.py CHANGED
@@ -11,7 +11,7 @@ class Getter[T](Protocol):
11
11
 
12
12
 
13
13
  class Setter[T](Protocol):
14
- def __call__(self, value: T): ...
14
+ def __call__(self, value: T) -> bool: ...
15
15
 
16
16
 
17
17
  def create_signal[T](initial_value: T = None, check_equality=True) -> tuple[Getter[T], Setter[T]]:
reactivity/helpers.py CHANGED
@@ -99,8 +99,8 @@ class Reactive[K, V](Subscribable, MutableMapping[K, V]):
99
99
 
100
100
  def __setitem__(self, key: K, value: V):
101
101
  with Batch(force_flush=False):
102
- self._signals[key].set(value)
103
- self.notify()
102
+ if self._signals[key].set(value):
103
+ self.notify()
104
104
 
105
105
  def __delitem__(self, key: K):
106
106
  state = self._signals[key]
reactivity/hmr/core.py CHANGED
@@ -19,17 +19,17 @@ from ..primitives import BaseDerived, Derived, Signal
19
19
  from .hooks import call_post_reload_hooks, call_pre_reload_hooks
20
20
 
21
21
 
22
- def is_called_in_this_file() -> bool:
23
- frame = currentframe() # this function
24
- assert frame is not None
22
+ def is_called_internally(*, extra_depth=0) -> bool:
23
+ """Protect private methods from being called from outside this package."""
25
24
 
26
- frame = frame.f_back # the function calling this function
25
+ frame = currentframe() # this function
27
26
  assert frame is not None
28
27
 
29
- frame = frame.f_back # the function calling the function calling this function
30
- assert frame is not None
28
+ for _ in range(extra_depth + 2):
29
+ frame = frame.f_back
30
+ assert frame is not None
31
31
 
32
- return frame.f_globals.get("__file__") == __file__
32
+ return frame.f_globals.get("__package__") == __package__
33
33
 
34
34
 
35
35
  class Name(Signal, BaseDerived):
@@ -83,7 +83,7 @@ class ReactiveModule(ModuleType):
83
83
 
84
84
  @property
85
85
  def file(self):
86
- if is_called_in_this_file():
86
+ if is_called_internally(extra_depth=1): # + 1 for `__getattribute__`
87
87
  return self.__file
88
88
  raise AttributeError("file")
89
89
 
@@ -106,7 +106,7 @@ class ReactiveModule(ModuleType):
106
106
 
107
107
  @property
108
108
  def load(self):
109
- if is_called_in_this_file():
109
+ if is_called_internally(extra_depth=1): # + 1 for `__getattribute__`
110
110
  return self.__load
111
111
  raise AttributeError("load")
112
112
 
@@ -127,7 +127,7 @@ class ReactiveModule(ModuleType):
127
127
  raise AttributeError(*e.args) from e
128
128
 
129
129
  def __setattr__(self, name: str, value):
130
- if is_called_in_this_file():
130
+ if is_called_internally():
131
131
  return super().__setattr__(name, value)
132
132
  self.__namespace_proxy[name] = value
133
133
 
@@ -338,4 +338,4 @@ def cli():
338
338
  SyncReloader(entry).keep_watching_until_interrupt()
339
339
 
340
340
 
341
- __version__ = "0.4.3"
341
+ __version__ = "0.5.1"
reactivity/hmr/utils.py CHANGED
@@ -61,3 +61,7 @@ def cache_across_reloads[T](func: Callable[[], T]) -> Callable[[], T]:
61
61
  class DictProxy(UserDict, dict): # type: ignore
62
62
  def __init__(self, data):
63
63
  self.data = data
64
+
65
+
66
+ def load(module: ReactiveModule):
67
+ return module.load()
reactivity/primitives.py CHANGED
@@ -72,6 +72,8 @@ class Signal[T](Subscribable):
72
72
  if not self._check_equality or self._value != value:
73
73
  self._value = value
74
74
  self.notify()
75
+ return True
76
+ return False
75
77
 
76
78
 
77
79
  class State[T](Signal[T]):
@@ -1,14 +0,0 @@
1
- hmr-0.4.3.dist-info/METADATA,sha256=gJvXslME9Vjx3o-BtCThGvA0a77QQ9ozUehjgosaY0I,258
2
- hmr-0.4.3.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
- hmr-0.4.3.dist-info/entry_points.txt,sha256=g_T0uJ43WgsdG14kkkdaBQuIL0HO-m1qvtjXMP6d060,59
4
- reactivity/__init__.py,sha256=pX-RUzkezCC1x4eOWGxNhXbwrbvBLP_3pQuZr9eZz1Y,300
5
- reactivity/functional.py,sha256=U06vshcVhZ0sb218gcmHtEhfgTNAGtQ7zyvPz2w5qKM,1292
6
- reactivity/helpers.py,sha256=DVwhsEEs9aRcsyMqTdF5eRG-Z0zVhS7AbmR-Y-PXCkg,5321
7
- reactivity/hmr/__init__.py,sha256=S5ZIHqCRpevdzWuhS0aCua_S8F0LkK0YNg6IgeTScFQ,177
8
- reactivity/hmr/__main__.py,sha256=uIcyjR5gMFIXH_3hS0B3SD00RirVf7GIct-uItx675o,64
9
- reactivity/hmr/api.py,sha256=Esb1fYiBW0SLxQ0MPXby25ZgIIZhIp-M3b2KiqpffmU,2094
10
- reactivity/hmr/core.py,sha256=97pqCf5wt0YOb5vAi4I1z9qagKXMEy_xQvL6LW9DHmI,11498
11
- reactivity/hmr/hooks.py,sha256=jIFpe4CNxfaS9RcR4OIodx_sOZlnJ_IA1T1RtHPXhwU,945
12
- reactivity/hmr/utils.py,sha256=-PO-LMP4sc3IP-Bn_baq2w9IFWBZ3zGesgRn5wR6bS0,1555
13
- reactivity/primitives.py,sha256=sPuIRi3pnAV7wV42rqD0j07HNkz4Bk4VxJWhdYToeZE,5907
14
- hmr-0.4.3.dist-info/RECORD,,
File without changes