soia-client 1.1.1__py3-none-any.whl → 1.1.2__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 soia-client might be problematic. Click here for more details.
- soia/_impl/enums.py +8 -2
- soia/reflection.py +29 -4
- {soia_client-1.1.1.dist-info → soia_client-1.1.2.dist-info}/METADATA +1 -1
- {soia_client-1.1.1.dist-info → soia_client-1.1.2.dist-info}/RECORD +7 -7
- {soia_client-1.1.1.dist-info → soia_client-1.1.2.dist-info}/WHEEL +0 -0
- {soia_client-1.1.1.dist-info → soia_client-1.1.2.dist-info}/licenses/LICENSE +0 -0
- {soia_client-1.1.1.dist-info → soia_client-1.1.2.dist-info}/top_level.txt +0 -0
soia/_impl/enums.py
CHANGED
|
@@ -3,12 +3,11 @@ from collections.abc import Callable, Sequence
|
|
|
3
3
|
from dataclasses import FrozenInstanceError, dataclass
|
|
4
4
|
from typing import Any, Final, Union
|
|
5
5
|
|
|
6
|
+
from soia import _spec, reflection
|
|
6
7
|
from soia._impl.function_maker import BodyBuilder, Expr, ExprLike, Line, make_function
|
|
7
8
|
from soia._impl.repr import repr_impl
|
|
8
9
|
from soia._impl.type_adapter import TypeAdapter
|
|
9
10
|
|
|
10
|
-
from soia import _spec, reflection
|
|
11
|
-
|
|
12
11
|
|
|
13
12
|
class EnumAdapter(TypeAdapter):
|
|
14
13
|
__slots__ = (
|
|
@@ -139,6 +138,13 @@ class EnumAdapter(TypeAdapter):
|
|
|
139
138
|
kind="enum",
|
|
140
139
|
id=record_id,
|
|
141
140
|
fields=tuple(
|
|
141
|
+
reflection.Field(
|
|
142
|
+
name=field.name,
|
|
143
|
+
number=field.number,
|
|
144
|
+
type=None,
|
|
145
|
+
)
|
|
146
|
+
for field in self.all_constant_fields if field.number != 0
|
|
147
|
+
) + tuple(
|
|
142
148
|
reflection.Field(
|
|
143
149
|
name=field.spec.name,
|
|
144
150
|
number=field.spec.number,
|
soia/reflection.py
CHANGED
|
@@ -109,11 +109,19 @@ class _Serializer(Generic[_T]):
|
|
|
109
109
|
from_json: Callable[[Any], _T]
|
|
110
110
|
|
|
111
111
|
|
|
112
|
+
@dataclass(frozen=True, eq=True)
|
|
113
|
+
class _NoDefault:
|
|
114
|
+
pass
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
_NO_DEFAULT: Final = _NoDefault()
|
|
118
|
+
|
|
119
|
+
|
|
112
120
|
@dataclass(frozen=True)
|
|
113
121
|
class _FieldSerializer(Generic[_T]):
|
|
114
122
|
name: str
|
|
115
123
|
serializer: _Serializer[_T]
|
|
116
|
-
default:
|
|
124
|
+
default: _T | _NoDefault = _NO_DEFAULT
|
|
117
125
|
|
|
118
126
|
|
|
119
127
|
def _primitive_serializer(check_type_fn: Callable[[Any], _T]) -> _Serializer[_T]:
|
|
@@ -144,7 +152,7 @@ def _dataclass_serializer(
|
|
|
144
152
|
def field_from_json(field: _FieldSerializer) -> Any:
|
|
145
153
|
value_json = json.get(field.name)
|
|
146
154
|
if value_json is None:
|
|
147
|
-
if field.default
|
|
155
|
+
if field.default != _NO_DEFAULT:
|
|
148
156
|
return field.default
|
|
149
157
|
else:
|
|
150
158
|
# Will raise an exception.
|
|
@@ -196,6 +204,22 @@ def _forwarding_serializer(
|
|
|
196
204
|
return _Serializer(to_json, from_json)
|
|
197
205
|
|
|
198
206
|
|
|
207
|
+
def _optional_serializer(
|
|
208
|
+
other_serializer: _Serializer[_T],
|
|
209
|
+
) -> _Serializer[Optional[_T]]:
|
|
210
|
+
def to_json(input: Optional[_T]) -> Any:
|
|
211
|
+
if input is None:
|
|
212
|
+
return None
|
|
213
|
+
return other_serializer.to_json(input)
|
|
214
|
+
|
|
215
|
+
def from_json(json: Any) -> Optional[_T]:
|
|
216
|
+
if json is None:
|
|
217
|
+
return None
|
|
218
|
+
return other_serializer.from_json(json)
|
|
219
|
+
|
|
220
|
+
return _Serializer(to_json, from_json)
|
|
221
|
+
|
|
222
|
+
|
|
199
223
|
# ==============================================================================
|
|
200
224
|
# INTERNAL: JSON serialization of TypeDescriptor
|
|
201
225
|
# ==============================================================================
|
|
@@ -292,9 +316,10 @@ _FIELD_SERIALIZER: Final = _dataclass_serializer(
|
|
|
292
316
|
"name",
|
|
293
317
|
_primitive_serializer(str),
|
|
294
318
|
),
|
|
295
|
-
_FieldSerializer(
|
|
319
|
+
_FieldSerializer[Optional[Type]](
|
|
296
320
|
"type",
|
|
297
|
-
_forwarding_serializer(_type_serializer),
|
|
321
|
+
_optional_serializer(_forwarding_serializer(_type_serializer)),
|
|
322
|
+
default=None,
|
|
298
323
|
),
|
|
299
324
|
_FieldSerializer(
|
|
300
325
|
"number",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
soia/__init__.py,sha256=WPhdlu7zKBSWd4DVFWXQKQoptD0gU7xGFm4tbQHrVc8,787
|
|
2
2
|
soia/_module_initializer.py,sha256=1TWnc0qUO7_iljQR2ywVERrrkY5jIkT3zucc-AYZyrQ,4221
|
|
3
3
|
soia/_spec.py,sha256=Y5EHHQa6qNeJc29aaqGrFPnPFXxlL7TED9_AXUGBjf0,3663
|
|
4
|
-
soia/reflection.py,sha256=
|
|
4
|
+
soia/reflection.py,sha256=SEFHNlzmWZEOQwoVUTIxzjjnbkiKSwo2rbpSU-qXhC4,9375
|
|
5
5
|
soia/_impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
soia/_impl/arrays.py,sha256=C3j3RZdSvqmogbGAi3EprLkUYMFfO-IJhoCOte5blAw,5477
|
|
7
|
-
soia/_impl/enums.py,sha256=
|
|
7
|
+
soia/_impl/enums.py,sha256=bpRtIWBioTGpy-oVA5Fo25RZH1TFBFzrmCXkuhZuC0k,17297
|
|
8
8
|
soia/_impl/function_maker.py,sha256=MvCDv1WwzKGJzZbNCnJ_8-MP3m1xTIabumXA-9Ydd9M,5639
|
|
9
9
|
soia/_impl/keep.py,sha256=GDeMKKUcvUFXWJVzBPB9CuLkcQb93sWKvo0PcyKUBzg,370
|
|
10
10
|
soia/_impl/keyed_items.py,sha256=EoPrdeLJ8i7zCH-oW-7qOcyadyrzykB6lkrf3xRVmyk,337
|
|
@@ -20,8 +20,8 @@ soia/_impl/service_client.py,sha256=0WgiN6Stg548FAdZQMuezZoooe4MYw2frEQ5KUE7xag,
|
|
|
20
20
|
soia/_impl/structs.py,sha256=1XhjZmqtD7IMURdSVR0DwMdrIhWPZft1eCfwVW84c0E,28230
|
|
21
21
|
soia/_impl/timestamp.py,sha256=upnEkvW-7AaMJ9_nNqntvhJ4pFWWCAXNjEOPtszdwgE,5645
|
|
22
22
|
soia/_impl/type_adapter.py,sha256=RyIyh4Fnt9rMy0HRzC-a2v2JAdZsV9FBzoGEUVygVRE,2101
|
|
23
|
-
soia_client-1.1.
|
|
24
|
-
soia_client-1.1.
|
|
25
|
-
soia_client-1.1.
|
|
26
|
-
soia_client-1.1.
|
|
27
|
-
soia_client-1.1.
|
|
23
|
+
soia_client-1.1.2.dist-info/licenses/LICENSE,sha256=SaAftKkX6hfSOiPdENQPS70tifH3PDHgazq8eK2Pwfw,1064
|
|
24
|
+
soia_client-1.1.2.dist-info/METADATA,sha256=gzME6YAXgQaA0ZCoU8Psh7Tf4HlBI-mJhnWnuH4t3l8,2121
|
|
25
|
+
soia_client-1.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
26
|
+
soia_client-1.1.2.dist-info/top_level.txt,sha256=lsYG9JrvauFe1oIV5zvnwsS9hsx3ztwfK_937op9mxc,5
|
|
27
|
+
soia_client-1.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|