soia-client 1.1.18__tar.gz → 1.1.20__tar.gz
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 soia-client might be problematic. Click here for more details.
- {soia_client-1.1.18/soia_client.egg-info → soia_client-1.1.20}/PKG-INFO +1 -1
- {soia_client-1.1.18 → soia_client-1.1.20}/pyproject.toml +1 -1
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/enums.py +2 -1
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/primitives.py +45 -2
- {soia_client-1.1.18 → soia_client-1.1.20/soia_client.egg-info}/PKG-INFO +1 -1
- {soia_client-1.1.18 → soia_client-1.1.20}/tests/test_serializers.py +7 -7
- {soia_client-1.1.18 → soia_client-1.1.20}/LICENSE +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/README.md +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/setup.cfg +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/__init__.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/__init__.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/arrays.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/binary.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/function_maker.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/keep.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/keyed_items.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/method.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/never.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/optionals.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/repr.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/serializer.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/serializers.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/service.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/service_client.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/structs.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/timestamp.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_impl/type_adapter.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_module_initializer.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/_spec.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia/reflection.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia_client.egg-info/SOURCES.txt +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia_client.egg-info/dependency_links.txt +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/soia_client.egg-info/top_level.txt +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/tests/test_module_initializer.py +0 -0
- {soia_client-1.1.18 → soia_client-1.1.20}/tests/test_timestamp.py +0 -0
|
@@ -630,7 +630,6 @@ def _make_decode_fn(
|
|
|
630
630
|
builder.append_ln(" try:")
|
|
631
631
|
builder.append_ln(" return ", number_to_constant_local, "[number]")
|
|
632
632
|
builder.append_ln(" except:")
|
|
633
|
-
builder.append_ln(" ", Expr.local("decode_unused", decode_unused), "(stream)")
|
|
634
633
|
if removed_numbers:
|
|
635
634
|
builder.append_ln(
|
|
636
635
|
f" if number in {removed_numbers_tuple} or not stream.keep_unrecognized_fields:"
|
|
@@ -671,6 +670,7 @@ def _make_decode_fn(
|
|
|
671
670
|
|
|
672
671
|
if not value_fields:
|
|
673
672
|
# The field was either removed or is an unrecognized field.
|
|
673
|
+
builder.append_ln(Expr.local("decode_unused", decode_unused), "(stream)")
|
|
674
674
|
if removed_numbers:
|
|
675
675
|
builder.append_ln(
|
|
676
676
|
f"if number in {removed_numbers_tuple} or not stream.keep_unrecognized_fields:"
|
|
@@ -680,6 +680,7 @@ def _make_decode_fn(
|
|
|
680
680
|
builder.append_ln("return ", unrecognized_class_local, "(0, bytes)")
|
|
681
681
|
else:
|
|
682
682
|
builder.append_ln(f"if number not in {value_field_numbers}:")
|
|
683
|
+
builder.append_ln(" ", Expr.local("decode_unused", decode_unused), "(stream)")
|
|
683
684
|
if removed_numbers:
|
|
684
685
|
builder.append_ln(
|
|
685
686
|
f" if number in {removed_numbers_tuple} or not stream.keep_unrecognized_fields:"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import base64
|
|
2
|
+
import math
|
|
2
3
|
import struct
|
|
3
4
|
from collections.abc import Callable
|
|
4
5
|
from dataclasses import dataclass
|
|
@@ -210,6 +211,20 @@ INT64_ADAPTER: Final[TypeAdapter[int]] = _Int64Adapter()
|
|
|
210
211
|
UINT64_ADAPTER: Final[TypeAdapter[int]] = _Uint64Adapter()
|
|
211
212
|
|
|
212
213
|
|
|
214
|
+
_SPECIAL_FLOAT_TO_STRING: Final[dict[str, str]] = {
|
|
215
|
+
"nan": "NaN",
|
|
216
|
+
"inf": "Infinity",
|
|
217
|
+
"-inf": "-Infinity",
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
_STRING_TO_SPECIAL_FLOAT: Final[dict[str, float]] = {
|
|
222
|
+
"NaN": float("nan"),
|
|
223
|
+
"Infinity": float("inf"),
|
|
224
|
+
"-Infinity": float("-inf"),
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
|
|
213
228
|
@dataclass(frozen=True)
|
|
214
229
|
class _AbstractFloatAdapter(AbstractPrimitiveAdapter[float]):
|
|
215
230
|
"""Type adapter implementation for float32 and float64."""
|
|
@@ -224,12 +239,40 @@ class _AbstractFloatAdapter(AbstractPrimitiveAdapter[float]):
|
|
|
224
239
|
return arg_expr
|
|
225
240
|
|
|
226
241
|
def to_json_expr(self, in_expr: ExprLike, readable: bool) -> ExprLike:
|
|
227
|
-
return
|
|
242
|
+
return Expr.join(
|
|
243
|
+
"(",
|
|
244
|
+
in_expr,
|
|
245
|
+
" if ",
|
|
246
|
+
Expr.local("_isfinite", math.isfinite),
|
|
247
|
+
"(",
|
|
248
|
+
in_expr,
|
|
249
|
+
") else ",
|
|
250
|
+
Expr.local(
|
|
251
|
+
"_SPECIAL_FLOAT_TO_STRING",
|
|
252
|
+
_SPECIAL_FLOAT_TO_STRING,
|
|
253
|
+
),
|
|
254
|
+
"[f'{",
|
|
255
|
+
in_expr,
|
|
256
|
+
"}'])",
|
|
257
|
+
)
|
|
228
258
|
|
|
229
259
|
def from_json_expr(
|
|
230
260
|
self, json_expr: ExprLike, keep_unrecognized_expr: ExprLike
|
|
231
261
|
) -> Expr:
|
|
232
|
-
return Expr.join(
|
|
262
|
+
return Expr.join(
|
|
263
|
+
"(",
|
|
264
|
+
Expr.local(
|
|
265
|
+
"_STRING_TO_SPECIAL_FLOAT",
|
|
266
|
+
_STRING_TO_SPECIAL_FLOAT,
|
|
267
|
+
),
|
|
268
|
+
"[",
|
|
269
|
+
json_expr,
|
|
270
|
+
"] if ",
|
|
271
|
+
json_expr,
|
|
272
|
+
" in ('NaN', 'Infinity', '-Infinity') else (",
|
|
273
|
+
json_expr,
|
|
274
|
+
" + 0.0))",
|
|
275
|
+
)
|
|
233
276
|
|
|
234
277
|
def decode_fn(self) -> Callable[[ByteStream], float]:
|
|
235
278
|
return decode_float
|
|
@@ -87,24 +87,24 @@ class SerializersTestCase(unittest.TestCase):
|
|
|
87
87
|
|
|
88
88
|
self.assertEqual(primitive_serializer("float32").to_json_code(3.14), "3.14")
|
|
89
89
|
self.assertEqual(
|
|
90
|
-
primitive_serializer("float32").to_json_code(float("inf")), "Infinity"
|
|
90
|
+
primitive_serializer("float32").to_json_code(float("inf")), '"Infinity"'
|
|
91
91
|
)
|
|
92
92
|
self.assertEqual(
|
|
93
|
-
primitive_serializer("float32").to_json_code(-float("inf")), "-Infinity"
|
|
93
|
+
primitive_serializer("float32").to_json_code(-float("inf")), '"-Infinity"'
|
|
94
94
|
)
|
|
95
95
|
self.assertEqual(
|
|
96
|
-
primitive_serializer("float32").to_json_code(float("nan")), "NaN"
|
|
96
|
+
primitive_serializer("float32").to_json_code(float("nan")), '"NaN"'
|
|
97
97
|
)
|
|
98
98
|
self.assertEqual(primitive_serializer("float32").from_json_code("3.14"), 3.14)
|
|
99
99
|
self.assertEqual(
|
|
100
|
-
primitive_serializer("float32").from_json_code("Infinity"), float("inf")
|
|
100
|
+
primitive_serializer("float32").from_json_code('"Infinity"'), float("inf")
|
|
101
101
|
)
|
|
102
102
|
self.assertEqual(
|
|
103
|
-
primitive_serializer("float32").from_json_code("-Infinity"), -float("inf")
|
|
103
|
+
primitive_serializer("float32").from_json_code('"-Infinity"'), -float("inf")
|
|
104
104
|
)
|
|
105
105
|
self.assertNotEqual(
|
|
106
|
-
primitive_serializer("float32").from_json_code("NaN"),
|
|
107
|
-
primitive_serializer("float32").from_json_code("NaN"),
|
|
106
|
+
primitive_serializer("float32").from_json_code('"NaN"'),
|
|
107
|
+
primitive_serializer("float32").from_json_code('"NaN"'),
|
|
108
108
|
)
|
|
109
109
|
|
|
110
110
|
self.assertEqual(primitive_serializer("float64").to_json_code(3.14), "3.14")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|