In version 1.3.0, kaleido switched to using orjson in the _KaleidoTab._calc_fig() method in src/py/kaleido/_kaleido_tab/_tab.py, but orjson doesn't support decimal.Decimal objects, resulting in an error.
import asyncio
from decimal import Decimal
import plotly.express as px
from kaleido import Kaleido
async def calc_kaleido_fig(fig):
async with Kaleido(n=1) as kaleido_context:
chart = await kaleido_context.calc_fig(fig)
return chart
int_fig = px.bar(x=[1, 2, 3], y=[10, 20, 30])
decimal_fig = px.bar(x=[1, 2, 3], y=[Decimal(10), Decimal(20), Decimal(30)])
asyncio.run(calc_kaleido_fig(int_fig))
# Binary output
asyncio.run(calc_kaleido_fig(decimal_fig))
# TypeError
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
File .venv/lib/python3.14/site-packages/kaleido/_kaleido_tab/_tab.py:32, in _orjson_default(obj)
31 return obj.tolist()
---> 32 raise TypeError(f"Type is not JSON serializable: {type(obj).__name__}")
TypeError: Type is not JSON serializable: Decimal
In version
1.3.0, kaleido switched to using orjson in the_KaleidoTab._calc_fig()method insrc/py/kaleido/_kaleido_tab/_tab.py, but orjson doesn't supportdecimal.Decimalobjects, resulting in an error.