pyglove 0.5.0.dev202507240811__py3-none-any.whl → 0.5.0.dev202507260809__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.

Potentially problematic release.


This version of pyglove might be problematic. Click here for more details.

@@ -23,7 +23,7 @@ import marshal
23
23
  import pickle
24
24
  import types
25
25
  import typing
26
- from typing import Any, Callable, ContextManager, Dict, Iterable, Iterator, List, Optional, Set, Tuple, Type, TypeVar, Union
26
+ from typing import Any, Callable, ContextManager, Dict, Iterable, Iterator, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union
27
27
 
28
28
  # Nestable[T] is a (maybe) nested structure of T, which could be T, a Dict
29
29
  # a List or a Tuple of Nestable[T]. We use a Union to fool PyType checker to
@@ -83,9 +83,16 @@ class _TypeRegistry:
83
83
  f'{self._type_to_cls_map[type_name].__name__}.')
84
84
  self._type_to_cls_map[type_name] = cls
85
85
 
86
- def add_module_alias(self, module: str, alias: str) -> None:
86
+ def add_module_alias(
87
+ self,
88
+ module: str,
89
+ alias: Union[str, Sequence[str]]
90
+ ) -> None:
87
91
  """Maps a module name to another name. Usually due to rename."""
88
- self._prefix_mapping[alias] = module
92
+ if isinstance(alias, str):
93
+ alias = [alias]
94
+ for name in alias:
95
+ self._prefix_mapping[name] = module
89
96
 
90
97
  def is_registered(self, type_name: str) -> bool:
91
98
  """Returns whether a type name is registered."""
@@ -245,9 +252,13 @@ class JSONConvertible(metaclass=abc.ABCMeta):
245
252
  cls._TYPE_REGISTRY.register(type_name, subclass, override_existing)
246
253
 
247
254
  @classmethod
248
- def add_module_alias(cls, source_name: str, target_name: str) -> None:
255
+ def add_module_alias(
256
+ cls,
257
+ module: str,
258
+ alias: Union[str, Sequence[str]]
259
+ ) -> None:
249
260
  """Adds a module alias so previous serialized objects could be loaded."""
250
- cls._TYPE_REGISTRY.add_module_alias(source_name, target_name)
261
+ cls._TYPE_REGISTRY.add_module_alias(module, alias)
251
262
 
252
263
  @classmethod
253
264
  def is_registered(cls, type_name: str) -> bool:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyglove
3
- Version: 0.5.0.dev202507240811
3
+ Version: 0.5.0.dev202507260809
4
4
  Summary: PyGlove: A library for manipulating Python objects.
5
5
  Home-page: https://github.com/google/pyglove
6
6
  Author: PyGlove Authors
@@ -147,7 +147,7 @@ pyglove/core/utils/formatting.py,sha256=Wn4d933LQLhuMIfjdRJgpxOThCxBxQrkRBa6Z1-h
147
147
  pyglove/core/utils/formatting_test.py,sha256=hhg-nL6DyE5A2QA92ALHK5QtfAYKfPpTbBARF-IT1j0,14241
148
148
  pyglove/core/utils/hierarchical.py,sha256=jwB-0FhqOspAymAkvJphRhPTQEsoShmKupCZpU3Vip4,19690
149
149
  pyglove/core/utils/hierarchical_test.py,sha256=f382DMJPa_bavJGGQDjuw-hWcafUg5bkQCPX-nbzeiI,21077
150
- pyglove/core/utils/json_conversion.py,sha256=fJ3zVvXJaoBf2OgUMYuYiSbRWuFg2PY82Vqzf9YohUc,26632
150
+ pyglove/core/utils/json_conversion.py,sha256=26Wt7VDU4df6fT_Joly-UzU87abkAQNL8gYDIh36fQ8,26785
151
151
  pyglove/core/utils/json_conversion_test.py,sha256=zA_cy7ixVL3sTf6i9BCXMlSH56Aa3JnjHnjyqYJ_9XU,11845
152
152
  pyglove/core/utils/missing.py,sha256=9gslt1lXd1qSEIuAFxUWu30oD-YdYcnm13eau1S9uqY,1445
153
153
  pyglove/core/utils/missing_test.py,sha256=D6-FuVEwCyJemUiPLcwLmwyptqI5Bx0Pfipc2juhKSE,1335
@@ -216,8 +216,8 @@ pyglove/ext/scalars/randoms.py,sha256=LkMIIx7lOq_lvJvVS3BrgWGuWl7Pi91-lA-O8x_gZs
216
216
  pyglove/ext/scalars/randoms_test.py,sha256=nEhiqarg8l_5EOucp59CYrpO2uKxS1pe0hmBdZUzRNM,2000
217
217
  pyglove/ext/scalars/step_wise.py,sha256=IDw3tuTpv0KVh7AN44W43zqm1-E0HWPUlytWOQC9w3Y,3789
218
218
  pyglove/ext/scalars/step_wise_test.py,sha256=TL1vJ19xVx2t5HKuyIzGoogF7N3Rm8YhLE6JF7i0iy8,2540
219
- pyglove-0.5.0.dev202507240811.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
220
- pyglove-0.5.0.dev202507240811.dist-info/METADATA,sha256=_GS4joAJ4qJ_2OFrIQ4gC--ML18KWBGqi_2in_-nZzs,7089
221
- pyglove-0.5.0.dev202507240811.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
222
- pyglove-0.5.0.dev202507240811.dist-info/top_level.txt,sha256=wITzJSKcj8GZUkbq-MvUQnFadkiuAv_qv5qQMw0fIow,8
223
- pyglove-0.5.0.dev202507240811.dist-info/RECORD,,
219
+ pyglove-0.5.0.dev202507260809.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
220
+ pyglove-0.5.0.dev202507260809.dist-info/METADATA,sha256=q-Ed_FCh7XUuuDaDhO0V4c9q-gtjvb9uuctIv2O1C40,7089
221
+ pyglove-0.5.0.dev202507260809.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
222
+ pyglove-0.5.0.dev202507260809.dist-info/top_level.txt,sha256=wITzJSKcj8GZUkbq-MvUQnFadkiuAv_qv5qQMw0fIow,8
223
+ pyglove-0.5.0.dev202507260809.dist-info/RECORD,,