Skip to content

Commit

Permalink
Remove % formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
squeaky-pl committed May 29, 2024
1 parent dc1e5b6 commit 05bc8c9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions inbox/sqlalchemy_ext/json_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def object_hook(dct):
return MaxKey()
if "$binary" in dct:
if isinstance(dct["$type"], int):
dct["$type"] = "%02x" % dct["$type"]
dct["$type"] = format(dct["$type"], "02x")
subtype = int(dct["$type"], 16)
if subtype >= 0xFFFFFF80: # Handle mongoexport values
subtype = int(dct["$type"][6:], 16)
Expand Down Expand Up @@ -239,11 +239,11 @@ def default(obj):
return SON(
[
("$binary", base64.b64encode(obj).decode()),
("$type", "%02x" % obj.subtype),
("$type", format(obj.subtype, "02x")),
]
)
if PY3 and isinstance(obj, bytes):
return SON([("$binary", base64.b64encode(obj).decode()), ("$type", "00")])
if isinstance(obj, uuid.UUID):
return {"$uuid": obj.hex}
raise TypeError("%r is not JSON serializable" % obj)
raise TypeError(f"{obj!r} is not JSON serializable")

0 comments on commit 05bc8c9

Please sign in to comment.