pyglove 0.5.0.dev202510310810__py3-none-any.whl → 0.5.0.dev202511020808__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.

@@ -506,8 +506,7 @@ class ListTest(unittest.TestCase):
506
506
  def test_index(self):
507
507
  sl = List([0, 1, 2, 1])
508
508
  self.assertEqual(sl.index(1), 1)
509
- with self.assertRaisesRegex(
510
- ValueError, '3 is not in list'):
509
+ with self.assertRaisesRegex(ValueError, '.* not in list'):
511
510
  _ = sl.index(3)
512
511
 
513
512
  # Index of inferred value is based on its symbolic form.
@@ -16,6 +16,7 @@
16
16
  import builtins
17
17
  import collections
18
18
  import inspect
19
+ import sys
19
20
  import types
20
21
  import typing
21
22
 
@@ -197,6 +198,8 @@ def annotation_from_str(
197
198
  def _resolve(type_id: str):
198
199
 
199
200
  def _as_forward_ref() -> typing.ForwardRef:
201
+ if sys.version_info >= (3, 14):
202
+ return typing.ForwardRef(type_id) # pytype: disable=not-callable
200
203
  return typing.ForwardRef(type_id, False, parent_module) # pytype: disable=not-callable
201
204
 
202
205
  def _resolve_name(name: str, parent_obj: typing.Any):
@@ -34,6 +34,12 @@ class Foo:
34
34
  _MODULE = sys.modules[__name__]
35
35
 
36
36
 
37
+ def typing_forward_ref(name: str) -> typing.ForwardRef:
38
+ if sys.version_info >= (3, 14):
39
+ return typing.ForwardRef(name)
40
+ return typing.ForwardRef(name, False, _MODULE)
41
+
42
+
37
43
  class AnnotationFromStrTest(unittest.TestCase):
38
44
  """Tests for annotation_from_str."""
39
45
 
@@ -69,7 +75,7 @@ class AnnotationFromStrTest(unittest.TestCase):
69
75
  )
70
76
  self.assertEqual(
71
77
  annotation_conversion.annotation_from_str('list[Foo.Baz]', _MODULE),
72
- list[typing.ForwardRef('Foo.Baz', False, _MODULE)]
78
+ list[typing_forward_ref('Foo.Baz')]
73
79
  )
74
80
 
75
81
  def test_generic_types(self):
@@ -138,18 +144,12 @@ class AnnotationFromStrTest(unittest.TestCase):
138
144
  self.assertEqual(
139
145
  annotation_conversion.annotation_from_str(
140
146
  'AAA', _MODULE),
141
- typing.ForwardRef(
142
- 'AAA', False, _MODULE
143
- )
147
+ typing_forward_ref('AAA')
144
148
  )
145
149
  self.assertEqual(
146
150
  annotation_conversion.annotation_from_str(
147
151
  'typing.List[AAA]', _MODULE),
148
- typing.List[
149
- typing.ForwardRef(
150
- 'AAA', False, _MODULE
151
- )
152
- ]
152
+ typing.List[typing_forward_ref('AAA')]
153
153
  )
154
154
 
155
155
  def test_reloading(self):
@@ -157,20 +157,12 @@ class AnnotationFromStrTest(unittest.TestCase):
157
157
  self.assertEqual(
158
158
  annotation_conversion.annotation_from_str(
159
159
  'typing.List[Foo]', _MODULE),
160
- typing.List[
161
- typing.ForwardRef(
162
- 'Foo', False, _MODULE
163
- )
164
- ]
160
+ typing.List[typing_forward_ref('Foo')]
165
161
  )
166
162
  self.assertEqual(
167
163
  annotation_conversion.annotation_from_str(
168
164
  'typing.List[Foo.Bar]', _MODULE),
169
- typing.List[
170
- typing.ForwardRef(
171
- 'Foo.Bar', False, _MODULE
172
- )
173
- ]
165
+ typing.List[typing_forward_ref('Foo.Bar')]
174
166
  )
175
167
  delattr(_MODULE, '__reloading__')
176
168
 
@@ -15,6 +15,7 @@
15
15
 
16
16
  import calendar
17
17
  import datetime
18
+ import sys
18
19
  from typing import Any, Callable, Optional, Tuple, Type, Union
19
20
 
20
21
  from pyglove.core import utils
@@ -135,9 +136,22 @@ def _register_builtin_converters():
135
136
  register_converter(int, float, float)
136
137
 
137
138
  # int <=> datetime.datetime.
138
- register_converter(int, datetime.datetime, datetime.datetime.utcfromtimestamp)
139
- register_converter(datetime.datetime, int,
140
- lambda x: calendar.timegm(x.timetuple()))
139
+ if sys.version_info >= (3, 11):
140
+ register_converter(
141
+ int,
142
+ datetime.datetime,
143
+ lambda x: datetime.datetime.fromtimestamp(x, datetime.UTC)
144
+ )
145
+ else:
146
+ register_converter(
147
+ int, datetime.datetime, datetime.datetime.utcfromtimestamp
148
+ )
149
+
150
+ register_converter(
151
+ datetime.datetime,
152
+ int,
153
+ lambda x: calendar.timegm(x.timetuple())
154
+ )
141
155
 
142
156
  # string <=> KeyPath.
143
157
  register_converter(str, utils.KeyPath, utils.KeyPath.parse)
@@ -130,7 +130,7 @@ class BuiltInConversionsTest(unittest.TestCase):
130
130
  def test_datetime_to_int(self):
131
131
  """Test built-in converter between int and datetime.datetime."""
132
132
  timestamp = calendar.timegm(datetime.datetime.now().timetuple())
133
- now = datetime.datetime.utcfromtimestamp(timestamp)
133
+ now = datetime.datetime.fromtimestamp(timestamp, datetime.UTC)
134
134
  self.assertEqual(vs.Object(datetime.datetime).apply(timestamp), now)
135
135
  self.assertEqual(vs.Int().apply(now), timestamp)
136
136
  self.assertEqual(
@@ -271,7 +271,8 @@ class JSONConvertibleTest(unittest.TestCase):
271
271
  self.assert_conversion_is(typing.List[typing.List[int]])
272
272
  self.assert_conversion_is(typing.Annotated[int, 'abc'])
273
273
  self.assert_conversion_is(typing.Dict[str, typing.Any])
274
- self.assert_conversion_is(typing.Union[int, str])
274
+ # From Python 3.14, union no longer preserves `is` identity.
275
+ self.assert_conversion_equal(typing.Union[int, str])
275
276
  self.assert_conversion_is(typing.Sequence[int])
276
277
  self.assert_conversion_is(typing.Set[int])
277
278
  self.assert_conversion_is(typing.FrozenSet[int])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyglove
3
- Version: 0.5.0.dev202510310810
3
+ Version: 0.5.0.dev202511020808
4
4
  Summary: PyGlove: A library for manipulating Python objects.
5
5
  Home-page: https://github.com/google/pyglove
6
6
  Author: PyGlove Authors
@@ -91,7 +91,7 @@ pyglove/core/symbolic/functor_test.py,sha256=9c5_7OBKNVNbYC7IaVQB6c5ks2v00qQ36oi
91
91
  pyglove/core/symbolic/inferred.py,sha256=E4zgphg6NNZad9Fl3jdHQOMZeqEp9XHq5OUYqXEmwZQ,3178
92
92
  pyglove/core/symbolic/inferred_test.py,sha256=G6uPykONcChvs6vZujXHSWaYfjewLTVBscMqzzKNty0,1270
93
93
  pyglove/core/symbolic/list.py,sha256=CRDoBxYJsmNly1MxhY5vO0wp6EUTnxze6-2O9vXHna4,30717
94
- pyglove/core/symbolic/list_test.py,sha256=Q3kqQ6aaQ40Nw6osSxrGk4N_E1lGZyvwdvxZgLRwMS0,61954
94
+ pyglove/core/symbolic/list_test.py,sha256=sH3wuJB6SqXVefJEPmzGVfoXc-ZiJ1ZTV4-O88LFuaM,61943
95
95
  pyglove/core/symbolic/object.py,sha256=UgDgKdcYDYX3J51EMQamdwaXHkG4SHPunAGkSuHuTa0,42768
96
96
  pyglove/core/symbolic/object_test.py,sha256=rDP7lcQZTFdQCqeaNYs7ZfwvGanzHz7CHM33NCmRIFk,94391
97
97
  pyglove/core/symbolic/origin.py,sha256=OSWMKjvPcISOXrzuX3lCQC8m_qaGl-9INsIB81erUnU,6124
@@ -113,8 +113,8 @@ pyglove/core/tuning/sample_test.py,sha256=JqwDPy3EPC_VjU9dipk90jj1kovZB3Zb9hAjAl
113
113
  pyglove/core/typing/__init__.py,sha256=u2YSrSi8diTkQn8_1J2hEpk5o7zDhx2tU_oRuS-k1XU,14580
114
114
  pyglove/core/typing/annotated.py,sha256=llaajIDj9GK-4kUGJoO4JsHU6ESPOra2SZ-jG6xmsOQ,3203
115
115
  pyglove/core/typing/annotated_test.py,sha256=p1qid3R-jeiOTTxOVq6hXW8XFvn-h1cUzJWISPst2l8,2484
116
- pyglove/core/typing/annotation_conversion.py,sha256=hi4LcRXwYzspHAKZ0rtXlq2dQyAmo9GXrm_HCJAGl34,15657
117
- pyglove/core/typing/annotation_conversion_test.py,sha256=g66iyt3ti_pskIXndk4DiKgO8j8aMYOe2nPKXszlXmw,17675
116
+ pyglove/core/typing/annotation_conversion.py,sha256=pnm6dZbn_nsTCreyarspkwpsdteMb8uFT2TLtblq_0M,15780
117
+ pyglove/core/typing/annotation_conversion_test.py,sha256=N49ZuzsmaqVi23wszDpfwcJApr2-Pk2E_ELrjssSQb0,17598
118
118
  pyglove/core/typing/annotation_future_test.py,sha256=tAVuzWNfW8R4e4l7fx88Q4nJDM2LPUogNKNAIIPAEWQ,3959
119
119
  pyglove/core/typing/callable_ext.py,sha256=PiBQWPeUAH7Lgmf2xKCZqgK7N0OSrTdbnEkV8Ph31OA,9127
120
120
  pyglove/core/typing/callable_ext_test.py,sha256=TnWKU4_ZjvpbHZFtFHgFvCMDiCos8VmLlODcM_7Xg8M,10156
@@ -130,8 +130,8 @@ pyglove/core/typing/json_schema_test.py,sha256=ZxMO2xgKiELNDzoQ84cmXsyCtFA0Ltn1I
130
130
  pyglove/core/typing/key_specs.py,sha256=-7xjCuUGoQgD0sMafsRFNlw3S4f1r-7t5OO4ev5bbeI,9225
131
131
  pyglove/core/typing/key_specs_test.py,sha256=5zornpyHMAYoRaG8KDXHiQ3obu9UfRp3399lBeUNTPk,6499
132
132
  pyglove/core/typing/pytype_support.py,sha256=lyX11WVbCwoOi5tTQ90pEOS-yvo_6iEi7Lxbp-nXu2A,2069
133
- pyglove/core/typing/type_conversion.py,sha256=0L4Cbsw_QiM-gpsn-4y-XLEIvwiUB16Clj9gCtoC_Xc,5224
134
- pyglove/core/typing/type_conversion_test.py,sha256=BhASOGvtKXmYLWKCELU1RVB_Nmt1V-saSkGogvsNL7E,5342
133
+ pyglove/core/typing/type_conversion.py,sha256=S_57FU-9DOk-MTE-1Mh31FMshaA3IoKiSDsoKxGxGv4,5432
134
+ pyglove/core/typing/type_conversion_test.py,sha256=mTPSzzCpQGTEBwmyPWA4lO1HvNHRywF5Xq2YNxmhfZU,5353
135
135
  pyglove/core/typing/typed_missing.py,sha256=-l1omAu0jBZv5BnsFYXBqfvQwVBnmPh_X1wcIKD9bOk,2734
136
136
  pyglove/core/typing/typed_missing_test.py,sha256=TCNsb1SRpFaVdxYn2mB_yaLuja8w5Qn5NP7uGiZVBWs,2301
137
137
  pyglove/core/typing/value_specs.py,sha256=8E83QDZMb3lMXhgzfVNt9u6Bg3NPkvpjLXetjkps8UU,103263
@@ -150,7 +150,7 @@ pyglove/core/utils/formatting_test.py,sha256=hhg-nL6DyE5A2QA92ALHK5QtfAYKfPpTbBA
150
150
  pyglove/core/utils/hierarchical.py,sha256=jwB-0FhqOspAymAkvJphRhPTQEsoShmKupCZpU3Vip4,19690
151
151
  pyglove/core/utils/hierarchical_test.py,sha256=f382DMJPa_bavJGGQDjuw-hWcafUg5bkQCPX-nbzeiI,21077
152
152
  pyglove/core/utils/json_conversion.py,sha256=V7wUviGKhEPWi1gtCGSDXXvBzV6cO7CvmEiGDZ2jWFY,34643
153
- pyglove/core/utils/json_conversion_test.py,sha256=6afuPJxBXIO-OxFzJBkv1MZqNX-44HIBD6YJjwxXSbs,13412
153
+ pyglove/core/utils/json_conversion_test.py,sha256=VB0_QKPqVFgiWilkm1OPH6hShjXIro0yLep1ftIucew,13480
154
154
  pyglove/core/utils/missing.py,sha256=9gslt1lXd1qSEIuAFxUWu30oD-YdYcnm13eau1S9uqY,1445
155
155
  pyglove/core/utils/missing_test.py,sha256=D6-FuVEwCyJemUiPLcwLmwyptqI5Bx0Pfipc2juhKSE,1335
156
156
  pyglove/core/utils/text_color.py,sha256=xcCTCxY2qFNZs_jismMGus8scEXKBpYGAhpAgnz-MHk,4112
@@ -218,8 +218,8 @@ pyglove/ext/scalars/randoms.py,sha256=LkMIIx7lOq_lvJvVS3BrgWGuWl7Pi91-lA-O8x_gZs
218
218
  pyglove/ext/scalars/randoms_test.py,sha256=nEhiqarg8l_5EOucp59CYrpO2uKxS1pe0hmBdZUzRNM,2000
219
219
  pyglove/ext/scalars/step_wise.py,sha256=IDw3tuTpv0KVh7AN44W43zqm1-E0HWPUlytWOQC9w3Y,3789
220
220
  pyglove/ext/scalars/step_wise_test.py,sha256=TL1vJ19xVx2t5HKuyIzGoogF7N3Rm8YhLE6JF7i0iy8,2540
221
- pyglove-0.5.0.dev202510310810.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
222
- pyglove-0.5.0.dev202510310810.dist-info/METADATA,sha256=thyDE29ZskF9vXNOcbWRtaLSo3Cgx2LHy224V74_YUI,7089
223
- pyglove-0.5.0.dev202510310810.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
224
- pyglove-0.5.0.dev202510310810.dist-info/top_level.txt,sha256=wITzJSKcj8GZUkbq-MvUQnFadkiuAv_qv5qQMw0fIow,8
225
- pyglove-0.5.0.dev202510310810.dist-info/RECORD,,
221
+ pyglove-0.5.0.dev202511020808.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
222
+ pyglove-0.5.0.dev202511020808.dist-info/METADATA,sha256=S6LLSLun1LSj-UDCBpVb-iOYoMqsMCwlEsGNzvfzUU8,7089
223
+ pyglove-0.5.0.dev202511020808.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
224
+ pyglove-0.5.0.dev202511020808.dist-info/top_level.txt,sha256=wITzJSKcj8GZUkbq-MvUQnFadkiuAv_qv5qQMw0fIow,8
225
+ pyglove-0.5.0.dev202511020808.dist-info/RECORD,,