#6326 [BUG] Pydantic type transformer (msgpack) can't deal with nan numbers
Issue created by
fg91
### Describe the bug
from flytekit.extras.pydantic_transformer.transformer import PydanticTransformer
from flytekit.core.context_manager import FlyteContext
from pydantic import BaseModel
ctx = FlyteContext.current_context()
tfm = PydanticTransformer()
class TestModel(BaseModel):
a: float
literal = tfm.to_literal(ctx, TestModel(a=float('nan')), TestModel, tfm.get_literal_type(TestModel))
print(literal)
reconstructed = tfm.to_python_value(ctx, literal, TestModel)
print(reconstructed, type(reconstructed))
ValidationError: 1 validation error for TestModel
a
Input should be a valid number [type=float_type, input_value=None, input_type=NoneType]
For further information visit
https://errors.pydantic.dev/2.10/v/float_type
### Expected behavior
I would have expected that the de-serialzed base model like the original contains a
float('nan')
.
### Additional context to reproduce
No response
### Screenshots
No response
### Are you sure this issue hasn't been raised already?
• Yes
### Have you read the Code of Conduct?
• Yes
flyteorg/flyte