You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a dataclass with a non-specialised list, NaNs are serialised in json mode as None, not NaN, even when ser_json_inf_nan is set to constants. This behaviour goes away if list[float] is used. But for my use case, the list might be arbitrarily nested (e.g. list[list[list[float]]]) so leaving it as list[Any] seems to be the only solution (unless recursive type aliases are supported).
Initial Checks
Description
When using a dataclass with a non-specialised list, NaNs are serialised in json mode as None, not NaN, even when
ser_json_inf_nan
is set to constants. This behaviour goes away iflist[float]
is used. But for my use case, the list might be arbitrarily nested (e.g.list[list[list[float]]]
) so leaving it aslist[Any]
seems to be the only solution (unless recursive type aliases are supported).Example Code
Python, Pydantic & OS Version
The text was updated successfully, but these errors were encountered: