mirror of
https://github.com/aphrody-labs/typesafe-sdk-python.git
synced 2026-10-14 04:19:06 +00:00
1 parent
c743d81416
commit
e70bf99a89
5 files changed
+25
-3
No files matched your search
@@ -5,6 +5,12 @@ icon: lucide/history
|
||||
|
||||
# Changelog
|
||||
|
||||
## v0.7.4 (2026-10-09)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- serialize non-finite numbers as strings instead of invalid JSON tokens
|
||||
|
||||
## v0.7.3 (2026-10-09)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "typesafe-sdk"
|
||||
version = "0.7.3"
|
||||
version = "0.7.4"
|
||||
description = "Python SDK for TypeSafe AI API."
|
||||
readme = "README.md"
|
||||
license = "MIT"
|
||||
|
||||
@@ -23,7 +23,8 @@ def _fallback(value: object) -> object:
|
||||
|
||||
|
||||
def serialize(value: object) -> bytes:
|
||||
return to_json(value, fallback=_fallback)
|
||||
# JSON has no NaN/Infinity tokens; emit them as the strings "NaN"/"Infinity"/"-Infinity" instead.
|
||||
return to_json(value, fallback=_fallback, inf_nan_mode="strings")
|
||||
|
||||
|
||||
def deserialize(content: bytes) -> Any:
|
||||
|
||||
@@ -161,6 +161,21 @@ async def test_unserializable_request_body_raises(clients: ClientFactory) -> Non
|
||||
)
|
||||
|
||||
|
||||
async def test_non_finite_numbers_are_stringified(clients: ClientFactory) -> None:
|
||||
def handler(request: httpx2.Request) -> httpx2.Response:
|
||||
body = from_json(request.content, allow_inf_nan=False)
|
||||
assert body["state"] == {"value": "NaN", "arr": [1.0, "Infinity", "-Infinity"]}
|
||||
assert body["temperature"] == "NaN"
|
||||
return httpx2.Response(200, content=to_json(RESULT))
|
||||
|
||||
await system_one(
|
||||
clients(handler),
|
||||
state={"value": float("nan"), "arr": [1.0, float("inf"), float("-inf")]},
|
||||
questions={"q": {"type": "noul", "instructions": "?"}},
|
||||
extra_body={"temperature": float("nan")},
|
||||
)
|
||||
|
||||
|
||||
async def test_raw_question_passthrough(clients: ClientFactory) -> None:
|
||||
# Explicit escape hatch for fields introduced by the API before this SDK models them.
|
||||
questions = cast(
|
||||
|
||||
Reference in new issue
Block a user