hmr 0.4.3__py3-none-any.whl → 0.5.0__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.0
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
@@ -1,14 +1,14 @@
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
1
+ hmr-0.5.0.dist-info/METADATA,sha256=BjQm4EMgr3JdiaLg1pibfu40LvQmRETerF3GyRYoa3o,258
2
+ hmr-0.5.0.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
+ hmr-0.5.0.dist-info/entry_points.txt,sha256=g_T0uJ43WgsdG14kkkdaBQuIL0HO-m1qvtjXMP6d060,59
4
4
  reactivity/__init__.py,sha256=pX-RUzkezCC1x4eOWGxNhXbwrbvBLP_3pQuZr9eZz1Y,300
5
5
  reactivity/functional.py,sha256=U06vshcVhZ0sb218gcmHtEhfgTNAGtQ7zyvPz2w5qKM,1292
6
6
  reactivity/helpers.py,sha256=DVwhsEEs9aRcsyMqTdF5eRG-Z0zVhS7AbmR-Y-PXCkg,5321
7
7
  reactivity/hmr/__init__.py,sha256=S5ZIHqCRpevdzWuhS0aCua_S8F0LkK0YNg6IgeTScFQ,177
8
8
  reactivity/hmr/__main__.py,sha256=uIcyjR5gMFIXH_3hS0B3SD00RirVf7GIct-uItx675o,64
9
9
  reactivity/hmr/api.py,sha256=Esb1fYiBW0SLxQ0MPXby25ZgIIZhIp-M3b2KiqpffmU,2094
10
- reactivity/hmr/core.py,sha256=97pqCf5wt0YOb5vAi4I1z9qagKXMEy_xQvL6LW9DHmI,11498
10
+ reactivity/hmr/core.py,sha256=ky7xaylCio8QWzg1nDK-krTmCu-h4fYTRChSyTFLrnY,11571
11
11
  reactivity/hmr/hooks.py,sha256=jIFpe4CNxfaS9RcR4OIodx_sOZlnJ_IA1T1RtHPXhwU,945
12
- reactivity/hmr/utils.py,sha256=-PO-LMP4sc3IP-Bn_baq2w9IFWBZ3zGesgRn5wR6bS0,1555
12
+ reactivity/hmr/utils.py,sha256=h9m7iRXlvsLTrHoXV9gEVbhz3XsPK4KgnStYoCAWE5I,1616
13
13
  reactivity/primitives.py,sha256=sPuIRi3pnAV7wV42rqD0j07HNkz4Bk4VxJWhdYToeZE,5907
14
- hmr-0.4.3.dist-info/RECORD,,
14
+ hmr-0.5.0.dist-info/RECORD,,
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.0"
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()
File without changes