new: convert nan and inf in local mode to none #603
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We forbid to add
nan
values to the payload in local mode, since the server does not allow to have them.An attempt to send a request with
nan
values fails.However, as of pydantic 2.7,
nan
values are converted tonull
, and such requests do not fail.pydantic/pydantic#8440
pydantic/pydantic-core#1251
Even if we'd like to supportnan
values in local mode whenpydantic>=2.7
is installed, there is no easy way to convertnan
values tonull
in local mode.This PR suggests to convert
nan
andinf
tonull
and aligns local mode withpydantic>=2.7
This PR suggests to disable such tests with the remote mode, we'll have a discrepancy then: local mode won't supportnan
values, server mode won't support them withpydantic<2.7
, and will support them withpydantic>=2.7
.One of the alternatives is to convert all thenan
s andinf
s to None manually, e.g. withAnother alternative which I also considered is to extend all the models, e.g. fromtoHowever, it won't work since we use construct and validation does not happen