Skip to content

Handling float strings #867

@umarbutler

Description

@umarbutler

Question

I like to use msgspec to parse YAML configs for training models. I find that when I define a struct to have a parameter that is a float and then, in my YAML config, I write a value like 0.00005 in scientific notation as 5e-5, I end up getting the error msgspec.ValidationError: Expected float, got str- at$.my_float_parameter`.

What is the best way to avoid that error without having to convert every float parameter into a float after an object is parsed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions