smithy-json 0.2.2__tar.gz → 0.3.0__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.
@@ -0,0 +1,8 @@
1
+ {
2
+ "changes": [
3
+ {
4
+ "type": "bugfix",
5
+ "description": "Serialize `IntEnum` members as their underlying integer instead of their `repr`."
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "changes": [
3
+ {
4
+ "type": "feature",
5
+ "description": "Added serialization and deserialization support for Smithy non-finite floating-point values (`NaN`, `Infinity`, and `-Infinity`) using their JSON string representations."
6
+ }
7
+ ]
8
+ }
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.3.0
4
+
5
+ ### Features
6
+ * Added serialization and deserialization support for Smithy non-finite floating-point values (`NaN`, `Infinity`, and `-Infinity`) using their JSON string representations.
7
+
8
+ ## v0.2.3
9
+
10
+ ### Bug fixes
11
+ * Serialize `IntEnum` members as their underlying integer instead of their `repr`.
12
+
3
13
  ## v0.2.2
4
14
 
5
15
  ### Enhancements
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: smithy-json
3
- Version: 0.2.2
3
+ Version: 0.3.0
4
4
  Summary: JSON serialization and deserialization support for Smithy tooling.
5
5
  Project-URL: Changelog, https://github.com/smithy-lang/smithy-python/blob/develop/packages/smithy-json/CHANGELOG.md
6
6
  Project-URL: Code, https://github.com/smithy-lang/smithy-python/blob/develop/packages/smithy-json/
@@ -21,6 +21,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
21
21
  Classifier: Programming Language :: Python :: 3.12
22
22
  Classifier: Programming Language :: Python :: 3.13
23
23
  Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Programming Language :: Python :: Free Threading :: 2 - Beta
24
25
  Classifier: Programming Language :: Python :: Implementation :: CPython
25
26
  Classifier: Topic :: Software Development :: Libraries
26
27
  Requires-Python: >=3.12
@@ -23,6 +23,7 @@ classifiers = [
23
23
  "Programming Language :: Python :: 3.13",
24
24
  "Programming Language :: Python :: 3.14",
25
25
  "Programming Language :: Python :: Implementation :: CPython",
26
+ "Programming Language :: Python :: Free Threading :: 2 - Beta",
26
27
  "Topic :: Software Development :: Libraries"
27
28
  ]
28
29
  dependencies = [
@@ -13,7 +13,7 @@ from ._private.documents import JSONDocument
13
13
  from ._private.serializers import JSONShapeSerializer as _JSONShapeSerializer
14
14
  from .settings import JSONSettings
15
15
 
16
- __version__ = "0.2.2"
16
+ __version__ = "0.3.0"
17
17
  __all__ = ("JSONCodec", "JSONDocument", "JSONSettings")
18
18
 
19
19
 
@@ -127,12 +127,10 @@ class JSONShapeDeserializer(ShapeDeserializer):
127
127
  def read_float(self, schema: Schema) -> float:
128
128
  event = next(self._stream)
129
129
  match event.value:
130
- case Decimal():
130
+ case Decimal() | "Infinity" | "-Infinity" | "NaN":
131
131
  return float(event.value)
132
132
  case int() | float():
133
133
  return event.value
134
- case "Infinity" | "-Infinity" | "NaN":
135
- return float(event.value)
136
134
  case _:
137
135
  raise JSONTokenError("number", event)
138
136
 
@@ -141,8 +139,8 @@ class JSONShapeDeserializer(ShapeDeserializer):
141
139
  match event.value:
142
140
  case Decimal():
143
141
  return event.value
144
- case int() | float():
145
- return Decimal.from_float(event.value)
142
+ case int() | float() | "Infinity" | "-Infinity" | "NaN":
143
+ return Decimal(event.value)
146
144
  case _:
147
145
  raise JSONTokenError("number", event)
148
146
 
@@ -300,7 +300,8 @@ class StreamingJSONEncoder:
300
300
  self._sink.write(b'"')
301
301
 
302
302
  def write_int(self, value: int) -> None:
303
- self._sink.write(repr(value).encode("utf-8"))
303
+ # int() unwraps IntEnum members; otherwise repr would emit "<MyEnum.A: 1>".
304
+ self._sink.write(str(int(value)).encode("utf-8"))
304
305
 
305
306
  def write_float(self, value: float | Decimal) -> None:
306
307
  if not self._write_non_numeric_float(value=value):
@@ -311,7 +312,7 @@ class StreamingJSONEncoder:
311
312
 
312
313
  def _write_non_numeric_float(self, value: float | Decimal) -> bool:
313
314
  if value != value:
314
- self._sink.write(b"NaN")
315
+ self._sink.write(b'"NaN"')
315
316
  return True
316
317
 
317
318
  if value == _INF:
File without changes
File without changes
File without changes