Skip to content
This repository has been archived by the owner on Aug 19, 2023. It is now read-only.

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

Open
lucascbeyeler opened this issue Jan 11, 2021 · 2 comments
Open

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

lucascbeyeler opened this issue Jan 11, 2021 · 2 comments
Labels
bug Something isn't working question Further information is requested

Comments

@lucascbeyeler
Copy link

lucascbeyeler commented Jan 11, 2021

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

@s-knibbs s-knibbs added the bug Something isn't working label Jan 24, 2021
@s-knibbs
Copy link
Owner

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

@s-knibbs s-knibbs added the question Further information is requested label Jan 24, 2021
@lucascbeyeler
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants