hmr 0.4.1__py3-none-any.whl → 0.4.1.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.4.1
3
+ Version: 0.4.1.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
@@ -1,14 +1,14 @@
1
- hmr-0.4.1.dist-info/METADATA,sha256=Zx1F2ZUK7Els9nM6w76ceL693CD7JAPUvf7uBVUS2LQ,258
2
- hmr-0.4.1.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
- hmr-0.4.1.dist-info/entry_points.txt,sha256=g_T0uJ43WgsdG14kkkdaBQuIL0HO-m1qvtjXMP6d060,59
1
+ hmr-0.4.1.2.dist-info/METADATA,sha256=VdPRpEn_Abq_5nmi3GZr9vGKNb-f2IhZSEfOalHdPhw,260
2
+ hmr-0.4.1.2.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
+ hmr-0.4.1.2.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
- reactivity/helpers.py,sha256=1KCpre2HTFZrngEKkI2HwSFMkCmsUCq2aPEbp0y3kKg,5140
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=HxPngNSKcw5OrIiokqJtbUfAw2Fph-1G3ToJIDP4Pf4,11677
10
+ reactivity/hmr/core.py,sha256=3FbPolLqcbbNvByAeFviyVsddki36n_Qq0310FqX3oE,11500
11
11
  reactivity/hmr/hooks.py,sha256=jIFpe4CNxfaS9RcR4OIodx_sOZlnJ_IA1T1RtHPXhwU,945
12
12
  reactivity/hmr/utils.py,sha256=-PO-LMP4sc3IP-Bn_baq2w9IFWBZ3zGesgRn5wR6bS0,1555
13
13
  reactivity/primitives.py,sha256=mB6cbHKDqtilOfgaEhshtRWJq9s0nPEKqRK0hfCoyFE,5671
14
- hmr-0.4.1.dist-info/RECORD,,
14
+ hmr-0.4.1.2.dist-info/RECORD,,
reactivity/helpers.py CHANGED
@@ -112,11 +112,13 @@ class Reactive[K, V](Subscribable, MutableMapping[K, V]):
112
112
 
113
113
  def __iter__(self):
114
114
  self.track()
115
- return iter(self._signals)
115
+ unset = self.UNSET
116
+ return (key for key, signal in self._signals.items() if signal.get(track=False) is not unset)
116
117
 
117
118
  def __len__(self):
118
119
  self.track()
119
- return len(self._signals)
120
+ unset = self.UNSET
121
+ return sum(signal.get(track=False) is not unset for signal in self._signals.values())
120
122
 
121
123
  def __repr__(self):
122
124
  self.track()
reactivity/hmr/core.py CHANGED
@@ -33,8 +33,7 @@ def is_called_in_this_file() -> bool:
33
33
 
34
34
 
35
35
  class Name(Signal, BaseDerived):
36
- def __init__(self, initial_value):
37
- super().__init__(initial_value)
36
+ pass
38
37
 
39
38
 
40
39
  class NamespaceProxy(Reactive[str, Any]):
@@ -44,7 +43,7 @@ class NamespaceProxy(Reactive[str, Any]):
44
43
  self.module = module
45
44
 
46
45
  def _null(self):
47
- self.module.load.subscribers.add(signal := Name(self.UNSET))
46
+ self.module.load.subscribers.add(signal := Name(self.UNSET, self._check_equality))
48
47
  signal.dependencies.add(self.module.load)
49
48
  return signal
50
49
 
@@ -97,8 +96,9 @@ class ReactiveModule(ModuleType):
97
96
  else:
98
97
  exec(code, self.__namespace, self.__namespace_proxy)
99
98
  finally:
100
- for dep in list((load := self.__load).dependencies):
101
- assert ismethod(load.fn) # for type narrowing
99
+ load = self.__load
100
+ assert ismethod(load.fn) # for type narrowing
101
+ for dep in list(load.dependencies):
102
102
  if isinstance(dep, Derived) and ismethod(dep.fn) and isinstance(dep.fn.__self__, ReactiveModule) and dep.fn.__func__ is load.fn.__func__:
103
103
  # unsubscribe it because we want invalidation to be fine-grained
104
104
  dep.subscribers.remove(load)
@@ -122,8 +122,7 @@ class ReactiveModule(ModuleType):
122
122
  try:
123
123
  return self.__namespace_proxy[name]
124
124
  except KeyError as e:
125
- caller = currentframe().f_back.f_globals["__name__"] # type: ignore
126
- if caller != "importlib._bootstrap" and (getattr := self.__namespace_proxy.get("__getattr__")):
125
+ if name != "__path__" and (getattr := self.__namespace_proxy.get("__getattr__")):
127
126
  return getattr(name)
128
127
  raise AttributeError(*e.args) from e
129
128
 
@@ -134,14 +133,13 @@ class ReactiveModule(ModuleType):
134
133
 
135
134
 
136
135
  class ReactiveModuleLoader(Loader):
137
- def __init__(self, file: Path, is_package=False):
136
+ def __init__(self, file: Path):
138
137
  super().__init__()
139
138
  self._file = file
140
- self._is_package = is_package
141
139
 
142
140
  def create_module(self, spec: ModuleSpec):
143
141
  namespace = {"__file__": str(self._file), "__spec__": spec, "__loader__": self, "__name__": spec.name}
144
- if self._is_package:
142
+ if spec.submodule_search_locations is not None:
145
143
  assert self._file.name == "__init__.py"
146
144
  namespace["__path__"] = [str(self._file.parent)]
147
145
  return ReactiveModule(self._file, namespace, spec.name)
@@ -174,7 +172,7 @@ class ReactiveModuleFinder(MetaPathFinder):
174
172
  return spec_from_loader(fullname, ReactiveModuleLoader(file), origin=str(file))
175
173
  file = directory / f"{fullname.replace('.', '/')}/__init__.py"
176
174
  if self._accept(file) and (paths is None or is_relative_to_any(file, paths)):
177
- return spec_from_loader(fullname, ReactiveModuleLoader(file, is_package=True), origin=str(file), is_package=True)
175
+ return spec_from_loader(fullname, ReactiveModuleLoader(file), origin=str(file), is_package=True)
178
176
 
179
177
 
180
178
  def is_relative_to_any(path: Path, paths: Iterable[str | Path]):
@@ -340,4 +338,4 @@ def cli():
340
338
  SyncReloader(entry).keep_watching_until_interrupt()
341
339
 
342
340
 
343
- __version__ = "0.4.1"
341
+ __version__ = "0.4.1.2"
File without changes