dataclasses-jsonschema icon indicating copy to clipboard operation
dataclasses-jsonschema copied to clipboard

UserWarning: Unable to decode value for "_field_name: float"

Open lucascbeyeler opened this issue 4 years ago • 2 comments

Hi

I need some help to fix this issue... for some reason whenever I try to use pyyaml and there is a float value in the middle of my YAML file, dataclasses-jsonschema starts to freak out with the error above.

While I was investigating I discover that the problem is that pyyaml returns ScalarFloat instead of float and dataclasses-jsonschema does not work with ScalarFloat. Do you know any way that I can enforce float values to be returned by pyyaml or if I can include ScalarFloat as part of this project?

Example:

from dataclasses import dataclass
from yaml import safe_load
from dataclasses_jsonschema import JsonSchemaMixin

class Example(JsonSchemaMixin):

    field: float
    
output = safe_load(<path_to_yaml>)
Example.from_dict(output)

Regards, Lucas Costa Beyeler

lucascbeyeler avatar Jan 11 '21 13:01 lucascbeyeler

Could you post a reproduction for this issue? For a workaround you could also try ruamel.yaml instead.

s-knibbs avatar Jan 24 '21 14:01 s-knibbs

Hi,

Thanks for taking time to see my message. I tried and I got a different error: UserWarning: Unable to create schema for 'ScalarFloat'

Regards, Lucas Costa Beyeler

lucascbeyeler avatar Jan 27 '21 10:01 lucascbeyeler