SimplyKnownAsG / yamlize

Python YAML serializing library
Apache License 2.0
11 stars 5 forks source link

Round trip parsing of integers into a float field adds an extra type specifier #16

Open lixinchin opened 2 years ago

lixinchin commented 2 years ago

Example:

import yamlize

class Test(yamlize.Object):
    field: float = yamlize.Attribute(type=float)

temp = Test.load("!Test\nfield: 10")
print(Test.dump(temp))

Expected output:

"!Test\nfield: 10.0\n"

Actual output:

"!Test\nfield: !!int '10.0'\n"
SimplyKnownAsG commented 2 years ago

Yea, that's wrong.

SimplyKnownAsG commented 2 years ago

This also seems pretty closely related to https://github.com/SimplyKnownAsG/yamlize/issues/15