hmr 0.4.0.2__py3-none-any.whl → 0.4.0.4__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.0.2
3
+ Version: 0.4.0.4
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.0.2.dist-info/METADATA,sha256=AxILguedqE7qPqsaQD9u0SJ4Zap0mNDOvOZoSS7ikVg,260
2
- hmr-0.4.0.2.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
- hmr-0.4.0.2.dist-info/entry_points.txt,sha256=g_T0uJ43WgsdG14kkkdaBQuIL0HO-m1qvtjXMP6d060,59
1
+ hmr-0.4.0.4.dist-info/METADATA,sha256=LUEgpV4DByNJUiBfSXLxwdbI0W1GcxaZlemWOA6BX7M,260
2
+ hmr-0.4.0.4.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
+ hmr-0.4.0.4.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=1KCpre2HTFZrngEKkI2HwSFMkCmsUCq2aPEbp0y3kKg,5140
7
7
  reactivity/hmr/__init__.py,sha256=S5ZIHqCRpevdzWuhS0aCua_S8F0LkK0YNg6IgeTScFQ,177
8
8
  reactivity/hmr/__main__.py,sha256=uIcyjR5gMFIXH_3hS0B3SD00RirVf7GIct-uItx675o,64
9
- reactivity/hmr/api.py,sha256=7GA-m25PofzvMigH-9JE4GTOC2Y5eLgvUeIgGUg0UcU,1845
10
- reactivity/hmr/core.py,sha256=AZ4ssyz5PUKP7h1c0fI3lYFdTOlFVz9sVOYvx3V420w,11559
9
+ reactivity/hmr/api.py,sha256=7_NitUF3MA8lepS3p_uTbPxZhFIGIXGxPu6iyRZP7o0,1916
10
+ reactivity/hmr/core.py,sha256=CB0QRElWIRMZGe4iDVJrH9B7vKM4R57_hOVh-EDRfqI,11679
11
11
  reactivity/hmr/hooks.py,sha256=-yLr5ktiyqPb1nDbHsgv6-c_ZkziBjNqCU-0PCfXGYU,592
12
12
  reactivity/hmr/utils.py,sha256=-PO-LMP4sc3IP-Bn_baq2w9IFWBZ3zGesgRn5wR6bS0,1555
13
13
  reactivity/primitives.py,sha256=mB6cbHKDqtilOfgaEhshtRWJq9s0nPEKqRK0hfCoyFE,5671
14
- hmr-0.4.0.2.dist-info/RECORD,,
14
+ hmr-0.4.0.4.dist-info/RECORD,,
reactivity/hmr/api.py CHANGED
@@ -1,20 +1,20 @@
1
- from .core import AsyncReloader, BaseReloader, SyncReloader
1
+ from .core import AsyncReloader, BaseReloader, SyncReloader, create_effect
2
2
  from .hooks import call_post_reload_hooks, call_pre_reload_hooks
3
3
 
4
4
 
5
- def _clean_up(r: BaseReloader):
6
- r.entry_module.load.dispose()
7
- r.entry_module.load.invalidate()
8
-
9
-
10
- class ReloadHooksMixin(BaseReloader):
5
+ class LifecycleMixin(BaseReloader):
11
6
  def run_with_hooks(self):
12
7
  call_pre_reload_hooks()
13
- self.run_entry_file()
8
+ self.effect = create_effect(self.run_entry_file)
14
9
  call_post_reload_hooks()
15
10
 
11
+ def clean_up(self):
12
+ self.effect.dispose()
13
+ self.entry_module.load.dispose()
14
+ self.entry_module.load.invalidate()
15
+
16
16
 
17
- class SyncReloaderAPI(SyncReloader, ReloadHooksMixin):
17
+ class SyncReloaderAPI(SyncReloader, LifecycleMixin):
18
18
  def __enter__(self):
19
19
  from threading import Thread
20
20
 
@@ -26,7 +26,7 @@ class SyncReloaderAPI(SyncReloader, ReloadHooksMixin):
26
26
  def __exit__(self, *_):
27
27
  self.stop_watching()
28
28
  self.thread.join()
29
- _clean_up(self)
29
+ self.clean_up()
30
30
 
31
31
  async def __aenter__(self):
32
32
  from asyncio import ensure_future, to_thread
@@ -38,10 +38,10 @@ class SyncReloaderAPI(SyncReloader, ReloadHooksMixin):
38
38
  async def __aexit__(self, *_):
39
39
  self.stop_watching()
40
40
  await self.future
41
- _clean_up(self)
41
+ self.clean_up()
42
42
 
43
43
 
44
- class AsyncReloaderAPI(AsyncReloader, ReloadHooksMixin):
44
+ class AsyncReloaderAPI(AsyncReloader, LifecycleMixin):
45
45
  def __enter__(self):
46
46
  from asyncio import run
47
47
  from threading import Thread
@@ -54,7 +54,7 @@ class AsyncReloaderAPI(AsyncReloader, ReloadHooksMixin):
54
54
  def __exit__(self, *_):
55
55
  self.stop_watching()
56
56
  self.thread.join()
57
- _clean_up(self)
57
+ self.clean_up()
58
58
 
59
59
  async def __aenter__(self):
60
60
  from asyncio import ensure_future, to_thread
@@ -66,4 +66,4 @@ class AsyncReloaderAPI(AsyncReloader, ReloadHooksMixin):
66
66
  async def __aexit__(self, *_):
67
67
  self.stop_watching()
68
68
  await self.future
69
- _clean_up(self)
69
+ self.clean_up()
reactivity/hmr/core.py CHANGED
@@ -122,7 +122,8 @@ class ReactiveModule(ModuleType):
122
122
  try:
123
123
  return self.__namespace_proxy[name]
124
124
  except KeyError as e:
125
- if getattr := self.__namespace_proxy.get("__getattr__"):
125
+ caller = currentframe().f_back.f_globals["__name__"] # type: ignore
126
+ if caller != "importlib._bootstrap" and (getattr := self.__namespace_proxy.get("__getattr__")):
126
127
  return getattr(name)
127
128
  raise AttributeError(*e.args) from e
128
129
 
@@ -339,4 +340,4 @@ def cli():
339
340
  SyncReloader(entry).keep_watching_until_interrupt()
340
341
 
341
342
 
342
- __version__ = "0.4.0.2"
343
+ __version__ = "0.4.0.4"
File without changes