soia-client 1.1.16__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.

Files changed (35) hide show
  1. {soia_client-1.1.16/soia_client.egg-info → soia_client-1.1.20}/PKG-INFO +1 -1
  2. {soia_client-1.1.16 → soia_client-1.1.20}/pyproject.toml +1 -1
  3. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/enums.py +2 -1
  4. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/primitives.py +45 -2
  5. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/structs.py +10 -11
  6. {soia_client-1.1.16 → soia_client-1.1.20/soia_client.egg-info}/PKG-INFO +1 -1
  7. {soia_client-1.1.16 → soia_client-1.1.20}/tests/test_serializers.py +7 -7
  8. {soia_client-1.1.16 → soia_client-1.1.20}/LICENSE +0 -0
  9. {soia_client-1.1.16 → soia_client-1.1.20}/README.md +0 -0
  10. {soia_client-1.1.16 → soia_client-1.1.20}/setup.cfg +0 -0
  11. {soia_client-1.1.16 → soia_client-1.1.20}/soia/__init__.py +0 -0
  12. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/__init__.py +0 -0
  13. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/arrays.py +0 -0
  14. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/binary.py +0 -0
  15. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/function_maker.py +0 -0
  16. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/keep.py +0 -0
  17. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/keyed_items.py +0 -0
  18. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/method.py +0 -0
  19. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/never.py +0 -0
  20. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/optionals.py +0 -0
  21. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/repr.py +0 -0
  22. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/serializer.py +0 -0
  23. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/serializers.py +0 -0
  24. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/service.py +0 -0
  25. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/service_client.py +0 -0
  26. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/timestamp.py +0 -0
  27. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_impl/type_adapter.py +0 -0
  28. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_module_initializer.py +0 -0
  29. {soia_client-1.1.16 → soia_client-1.1.20}/soia/_spec.py +0 -0
  30. {soia_client-1.1.16 → soia_client-1.1.20}/soia/reflection.py +0 -0
  31. {soia_client-1.1.16 → soia_client-1.1.20}/soia_client.egg-info/SOURCES.txt +0 -0
  32. {soia_client-1.1.16 → soia_client-1.1.20}/soia_client.egg-info/dependency_links.txt +0 -0
  33. {soia_client-1.1.16 → soia_client-1.1.20}/soia_client.egg-info/top_level.txt +0 -0
  34. {soia_client-1.1.16 → soia_client-1.1.20}/tests/test_module_initializer.py +0 -0
  35. {soia_client-1.1.16 → soia_client-1.1.20}/tests/test_timestamp.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: soia-client
3
- Version: 1.1.16
3
+ Version: 1.1.20
4
4
  Author-email: Tyler Fibonacci <gepheum@gmail.com>
5
5
  License: MIT License
6
6
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "soia-client"
7
- version = "1.1.16"
7
+ version = "1.1.20"
8
8
  description = ""
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Tyler Fibonacci", email = "gepheum@gmail.com" }]
@@ -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 in_expr
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("(", json_expr, " + 0.0)")
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
@@ -852,14 +852,6 @@ def _make_from_json_fn(
852
852
  f" if array_len <= {num_slots_incl_removed} or not keep_unrecognized_fields:"
853
853
  )
854
854
  builder.append_ln(" ret._unrecognized = None")
855
- builder.append_ln(
856
- " ret._array_len = ",
857
- _adjust_array_len_expr(
858
- "array_len",
859
- removed_numbers=removed_numbers,
860
- num_slots_excl_removed=num_slots_excl_removed,
861
- ),
862
- )
863
855
  builder.append_ln(" else:")
864
856
  builder.append_ln(
865
857
  " ret._unrecognized = ",
@@ -868,7 +860,14 @@ def _make_from_json_fn(
868
860
  Expr.local("deepcopy", copy.deepcopy),
869
861
  f"(json[{num_slots_incl_removed}:]), adjusted_json_array_len=array_len)",
870
862
  )
871
- builder.append_ln(f" ret._array_len = {num_slots_excl_removed}")
863
+ builder.append_ln(
864
+ " ret._array_len = ",
865
+ _adjust_array_len_expr(
866
+ "array_len",
867
+ removed_numbers=removed_numbers,
868
+ num_slots_excl_removed=num_slots_excl_removed,
869
+ ),
870
+ )
872
871
 
873
872
  builder.append_ln("else:")
874
873
  builder.append_ln(" array_len = 0")
@@ -953,7 +952,7 @@ def _make_decode_fn(
953
952
  " ", Expr.local("decode_unused", decode_unused), "(stream)"
954
953
  )
955
954
  builder.append_ln(" start_offset = stream.position")
956
- builder.append_ln(" for _ in range(array_len - {num_slots_incl_removed}):")
955
+ builder.append_ln(f" for _ in range(array_len - {num_slots_incl_removed}):")
957
956
  builder.append_ln(" ", Expr.local("decode_unused", decode_unused), "(stream)")
958
957
  builder.append_ln(" end_offset = stream.position")
959
958
  builder.append_ln(
@@ -969,7 +968,7 @@ def _make_decode_fn(
969
968
  builder.append_ln(" ret._unrecognized = None")
970
969
 
971
970
  builder.append_ln(
972
- " ret._array_len = ",
971
+ "ret._array_len = ",
973
972
  _adjust_array_len_expr(
974
973
  "array_len",
975
974
  removed_numbers=removed_numbers,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: soia-client
3
- Version: 1.1.16
3
+ Version: 1.1.20
4
4
  Author-email: Tyler Fibonacci <gepheum@gmail.com>
5
5
  License: MIT License
6
6
 
@@ -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