kdlpy icon indicating copy to clipboard operation
kdlpy copied to clipboard

Shouldn't 1 be parsed as an int instead of becoming a float?

Open eugenesvk opened this issue 2 years ago • 1 comments

I've noticed that with nativeUntaggedValues: bool = True that's supposed to

produces native Python objects (str, int, float, bool, None) when parsing untagged values

I get 1 parsed as 3.0 <class 'float'>, and while float is a native object, how would I ever get an int from an untagged value if such simple numbers become floats?

eugenesvk avatar Jan 27 '24 15:01 eugenesvk

Yeah, I'm currently just doing a parseFloat() for simplicity. I ran into this as well and got annoyed with it (another project I'm working on had to sprinkle int() casts around to make mypy happy). I should probably detect when the value is an int and return it as such.

tabatkins avatar Jan 28 '24 19:01 tabatkins