soia-client 1.1.9__tar.gz → 1.1.16__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.9/soia_client.egg-info → soia_client-1.1.16}/PKG-INFO +1 -1
- {soia_client-1.1.9 → soia_client-1.1.16}/pyproject.toml +1 -1
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/arrays.py +2 -2
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/enums.py +3 -3
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/primitives.py +24 -10
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/structs.py +1 -1
- {soia_client-1.1.9 → soia_client-1.1.16/soia_client.egg-info}/PKG-INFO +1 -1
- {soia_client-1.1.9 → soia_client-1.1.16}/tests/test_serializers.py +16 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/LICENSE +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/README.md +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/setup.cfg +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/__init__.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/__init__.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/binary.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/function_maker.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/keep.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/keyed_items.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/method.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/never.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/optionals.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/repr.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/serializer.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/serializers.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/service.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/service_client.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/timestamp.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_impl/type_adapter.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_module_initializer.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/_spec.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia/reflection.py +4 -4
- {soia_client-1.1.9 → soia_client-1.1.16}/soia_client.egg-info/SOURCES.txt +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia_client.egg-info/dependency_links.txt +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/soia_client.egg-info/top_level.txt +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/tests/test_module_initializer.py +0 -0
- {soia_client-1.1.9 → soia_client-1.1.16}/tests/test_timestamp.py +0 -0
|
@@ -98,9 +98,9 @@ class _ArrayAdapter(Generic[T], TypeAdapter[tuple[T, ...]]):
|
|
|
98
98
|
listuple_class_local,
|
|
99
99
|
"([",
|
|
100
100
|
self.item_adapter.from_json_expr("_e", keep_unrecognized_expr),
|
|
101
|
-
" for _e in ",
|
|
101
|
+
" for _e in (",
|
|
102
102
|
json_expr,
|
|
103
|
-
"] or ",
|
|
103
|
+
" or ())] or ",
|
|
104
104
|
empty_listuple_local,
|
|
105
105
|
")",
|
|
106
106
|
)
|
|
@@ -633,7 +633,7 @@ def _make_decode_fn(
|
|
|
633
633
|
builder.append_ln(" ", Expr.local("decode_unused", decode_unused), "(stream)")
|
|
634
634
|
if removed_numbers:
|
|
635
635
|
builder.append_ln(
|
|
636
|
-
f" if number in {removed_numbers_tuple} or not keep_unrecognized_fields:"
|
|
636
|
+
f" if number in {removed_numbers_tuple} or not stream.keep_unrecognized_fields:"
|
|
637
637
|
)
|
|
638
638
|
builder.append_ln(" return ", unknown_constant_local)
|
|
639
639
|
builder.append_ln(" bytes = stream.buffer[start_offset:stream.position]")
|
|
@@ -673,7 +673,7 @@ def _make_decode_fn(
|
|
|
673
673
|
# The field was either removed or is an unrecognized field.
|
|
674
674
|
if removed_numbers:
|
|
675
675
|
builder.append_ln(
|
|
676
|
-
f"if number in {removed_numbers_tuple} or not keep_unrecognized_fields:"
|
|
676
|
+
f"if number in {removed_numbers_tuple} or not stream.keep_unrecognized_fields:"
|
|
677
677
|
)
|
|
678
678
|
builder.append_ln(" return ", unknown_constant_local)
|
|
679
679
|
builder.append_ln("bytes = stream.buffer[start_offset:stream.position]")
|
|
@@ -682,7 +682,7 @@ def _make_decode_fn(
|
|
|
682
682
|
builder.append_ln(f"if number not in {value_field_numbers}:")
|
|
683
683
|
if removed_numbers:
|
|
684
684
|
builder.append_ln(
|
|
685
|
-
f" if number in {removed_numbers_tuple} or not keep_unrecognized_fields:"
|
|
685
|
+
f" if number in {removed_numbers_tuple} or not stream.keep_unrecognized_fields:"
|
|
686
686
|
)
|
|
687
687
|
builder.append_ln(" return ", unknown_constant_local)
|
|
688
688
|
builder.append_ln(" bytes = stream.buffer[start_offset:stream.position]")
|
|
@@ -66,7 +66,7 @@ class _BoolAdapter(AbstractPrimitiveAdapter[bool]):
|
|
|
66
66
|
def from_json_expr(
|
|
67
67
|
self, json_expr: ExprLike, keep_unrecognized_expr: ExprLike
|
|
68
68
|
) -> Expr:
|
|
69
|
-
return Expr.join("(
|
|
69
|
+
return Expr.join("(", json_expr, " not in (0, '0'))")
|
|
70
70
|
|
|
71
71
|
@staticmethod
|
|
72
72
|
def encode(
|
|
@@ -339,7 +339,7 @@ class _TimestampAdapter(AbstractPrimitiveAdapter[Timestamp]):
|
|
|
339
339
|
def _timestamp_from_json(json: Any) -> Timestamp:
|
|
340
340
|
if json.__class__ is int or isinstance(json, int):
|
|
341
341
|
return Timestamp(unix_millis=json)
|
|
342
|
-
elif isinstance(json, float):
|
|
342
|
+
elif isinstance(json, float) or isinstance(json, str):
|
|
343
343
|
return Timestamp(unix_millis=int(json))
|
|
344
344
|
else:
|
|
345
345
|
return Timestamp(unix_millis=json["unix_millis"])
|
|
@@ -386,7 +386,7 @@ class _StringAdapter(AbstractPrimitiveAdapter[str]):
|
|
|
386
386
|
@staticmethod
|
|
387
387
|
def decode(stream: ByteStream) -> str:
|
|
388
388
|
wire = stream.read(1)[0]
|
|
389
|
-
if wire
|
|
389
|
+
if wire in (0, 242):
|
|
390
390
|
return ""
|
|
391
391
|
else:
|
|
392
392
|
# Should be wire 243
|
|
@@ -407,6 +407,13 @@ class _StringAdapter(AbstractPrimitiveAdapter[str]):
|
|
|
407
407
|
STRING_ADAPTER: Final[TypeAdapter] = _StringAdapter()
|
|
408
408
|
|
|
409
409
|
|
|
410
|
+
def _bytes_from_json(json: str) -> bytes:
|
|
411
|
+
if json.startswith("hex:"):
|
|
412
|
+
return bytes.fromhex(json[4:])
|
|
413
|
+
else:
|
|
414
|
+
return base64.b64decode(json)
|
|
415
|
+
|
|
416
|
+
|
|
410
417
|
class _BytesAdapter(AbstractPrimitiveAdapter[bytes]):
|
|
411
418
|
def default_expr(self) -> ExprLike:
|
|
412
419
|
return 'b""'
|
|
@@ -422,18 +429,25 @@ class _BytesAdapter(AbstractPrimitiveAdapter[bytes]):
|
|
|
422
429
|
in_expr: ExprLike,
|
|
423
430
|
readable: bool,
|
|
424
431
|
) -> Expr:
|
|
425
|
-
|
|
426
|
-
Expr.
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
432
|
+
if readable:
|
|
433
|
+
return Expr.join(
|
|
434
|
+
"('hex:' + ",
|
|
435
|
+
in_expr,
|
|
436
|
+
".hex())",
|
|
437
|
+
)
|
|
438
|
+
else:
|
|
439
|
+
return Expr.join(
|
|
440
|
+
Expr.local("b64encode", base64.b64encode),
|
|
441
|
+
"(",
|
|
442
|
+
in_expr,
|
|
443
|
+
").decode('utf-8')",
|
|
444
|
+
)
|
|
431
445
|
|
|
432
446
|
def from_json_expr(
|
|
433
447
|
self, json_expr: ExprLike, keep_unrecognized_expr: ExprLike
|
|
434
448
|
) -> Expr:
|
|
435
449
|
return Expr.join(
|
|
436
|
-
Expr.local("
|
|
450
|
+
Expr.local("bytes_from_json", _bytes_from_json), "(", json_expr, ' or "")'
|
|
437
451
|
)
|
|
438
452
|
|
|
439
453
|
@staticmethod
|
|
@@ -946,7 +946,7 @@ def _make_decode_fn(
|
|
|
946
946
|
|
|
947
947
|
builder.append_ln(f"if array_len > {num_slots_excl_removed}:")
|
|
948
948
|
builder.append_ln(
|
|
949
|
-
f" if array_len > {num_slots_incl_removed} and keep_unrecognized_fields:"
|
|
949
|
+
f" if array_len > {num_slots_incl_removed} and stream.keep_unrecognized_fields:"
|
|
950
950
|
)
|
|
951
951
|
for _ in range(num_slots_incl_removed - num_slots_excl_removed):
|
|
952
952
|
builder.append_ln(
|
|
@@ -13,6 +13,9 @@ class SerializersTestCase(unittest.TestCase):
|
|
|
13
13
|
self.assertEqual(primitive_serializer("bool").from_json_code("true"), True)
|
|
14
14
|
self.assertEqual(primitive_serializer("bool").from_json_code("false"), False)
|
|
15
15
|
self.assertEqual(primitive_serializer("bool").from_json_code("0"), False)
|
|
16
|
+
self.assertEqual(primitive_serializer("bool").from_json_code('"0"'), False)
|
|
17
|
+
self.assertEqual(primitive_serializer("bool").from_json_code("1"), True)
|
|
18
|
+
self.assertEqual(primitive_serializer("bool").from_json_code('"1"'), True)
|
|
16
19
|
|
|
17
20
|
self.assertEqual(primitive_serializer("int32").to_json_code(7), "7")
|
|
18
21
|
self.assertEqual(
|
|
@@ -144,6 +147,19 @@ class SerializersTestCase(unittest.TestCase):
|
|
|
144
147
|
),
|
|
145
148
|
"[\n true,\n false\n]",
|
|
146
149
|
)
|
|
150
|
+
self.assertEqual(
|
|
151
|
+
array_serializer(primitive_serializer("bool")).from_json_code(
|
|
152
|
+
"[ true, false ]"
|
|
153
|
+
),
|
|
154
|
+
(
|
|
155
|
+
True,
|
|
156
|
+
False,
|
|
157
|
+
),
|
|
158
|
+
)
|
|
159
|
+
self.assertEqual(
|
|
160
|
+
array_serializer(primitive_serializer("bool")).from_json_code("0"),
|
|
161
|
+
(),
|
|
162
|
+
)
|
|
147
163
|
|
|
148
164
|
def test_optional_serializer(self):
|
|
149
165
|
self.assertEqual(
|
|
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
|
|
@@ -316,15 +316,15 @@ _FIELD_SERIALIZER: Final = _dataclass_serializer(
|
|
|
316
316
|
"name",
|
|
317
317
|
_primitive_serializer(str),
|
|
318
318
|
),
|
|
319
|
+
_FieldSerializer(
|
|
320
|
+
"number",
|
|
321
|
+
_primitive_serializer(int),
|
|
322
|
+
),
|
|
319
323
|
_FieldSerializer[Optional[Type]](
|
|
320
324
|
"type",
|
|
321
325
|
_optional_serializer(_forwarding_serializer(_type_serializer)),
|
|
322
326
|
default=None,
|
|
323
327
|
),
|
|
324
|
-
_FieldSerializer(
|
|
325
|
-
"number",
|
|
326
|
-
_primitive_serializer(int),
|
|
327
|
-
),
|
|
328
328
|
],
|
|
329
329
|
)
|
|
330
330
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|