Make safe_json return None on parse error

This commit is contained in:
Rafael Moraes
2026-02-23 21:44:47 -03:00
parent a7c8ff4297
commit 42df1f7f5e
+2 -2
View File
@@ -14,11 +14,11 @@ def raise_for_status(httpx_response: httpx.Response, valid_responses: set[int] =
)
def safe_json(httpx_response: httpx.Response) -> dict:
def safe_json(httpx_response: httpx.Response) -> dict | None:
try:
return httpx_response.json()
except (json.JSONDecodeError, UnicodeDecodeError):
return {}
return None
async def get_response(