soia-client 1.1.11__tar.gz → 1.1.13__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.11/soia_client.egg-info → soia_client-1.1.13}/PKG-INFO +1 -1
  2. {soia_client-1.1.11 → soia_client-1.1.13}/pyproject.toml +1 -1
  3. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/arrays.py +2 -2
  4. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/primitives.py +21 -7
  5. {soia_client-1.1.11 → soia_client-1.1.13/soia_client.egg-info}/PKG-INFO +1 -1
  6. {soia_client-1.1.11 → soia_client-1.1.13}/tests/test_serializers.py +13 -0
  7. {soia_client-1.1.11 → soia_client-1.1.13}/LICENSE +0 -0
  8. {soia_client-1.1.11 → soia_client-1.1.13}/README.md +0 -0
  9. {soia_client-1.1.11 → soia_client-1.1.13}/setup.cfg +0 -0
  10. {soia_client-1.1.11 → soia_client-1.1.13}/soia/__init__.py +0 -0
  11. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/__init__.py +0 -0
  12. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/binary.py +0 -0
  13. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/enums.py +0 -0
  14. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/function_maker.py +0 -0
  15. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/keep.py +0 -0
  16. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/keyed_items.py +0 -0
  17. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/method.py +0 -0
  18. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/never.py +0 -0
  19. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/optionals.py +0 -0
  20. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/repr.py +0 -0
  21. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/serializer.py +0 -0
  22. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/serializers.py +0 -0
  23. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/service.py +0 -0
  24. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/service_client.py +0 -0
  25. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/structs.py +0 -0
  26. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/timestamp.py +0 -0
  27. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_impl/type_adapter.py +0 -0
  28. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_module_initializer.py +0 -0
  29. {soia_client-1.1.11 → soia_client-1.1.13}/soia/_spec.py +0 -0
  30. {soia_client-1.1.11 → soia_client-1.1.13}/soia/reflection.py +0 -0
  31. {soia_client-1.1.11 → soia_client-1.1.13}/soia_client.egg-info/SOURCES.txt +0 -0
  32. {soia_client-1.1.11 → soia_client-1.1.13}/soia_client.egg-info/dependency_links.txt +0 -0
  33. {soia_client-1.1.11 → soia_client-1.1.13}/soia_client.egg-info/top_level.txt +0 -0
  34. {soia_client-1.1.11 → soia_client-1.1.13}/tests/test_module_initializer.py +0 -0
  35. {soia_client-1.1.11 → soia_client-1.1.13}/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.11
3
+ Version: 1.1.13
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.11"
7
+ version = "1.1.13"
8
8
  description = ""
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Tyler Fibonacci", email = "gepheum@gmail.com" }]
@@ -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
  )
@@ -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
- return Expr.join(
426
- Expr.local("b64encode", base64.b64encode),
427
- "(",
428
- in_expr,
429
- ").decode('utf-8')",
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("b64decode", base64.b64decode), "(", json_expr, ' or "")'
450
+ Expr.local("bytes_from_json", _bytes_from_json), "(", json_expr, ' or "")'
437
451
  )
438
452
 
439
453
  @staticmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: soia-client
3
- Version: 1.1.11
3
+ Version: 1.1.13
4
4
  Author-email: Tyler Fibonacci <gepheum@gmail.com>
5
5
  License: MIT License
6
6
 
@@ -147,6 +147,19 @@ class SerializersTestCase(unittest.TestCase):
147
147
  ),
148
148
  "[\n true,\n false\n]",
149
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
+ )
150
163
 
151
164
  def test_optional_serializer(self):
152
165
  self.assertEqual(
File without changes
File without changes
File without changes
File without changes